一个有趣的vc1编码器

news2024/9/20 8:12:36

这里分享一个vc1编码器,下载地址:
https://download.csdn.net/download/weixin_43360707/87791898

文件包在附件,打开文件夹,可以看到下面三个文件夹:
在这里插入图片描述
因为我们的系统试Linux,所以我们选择Linux(x64).

继续打开,可以看到以下文件夹:
在这里插入图片描述

cd bin

chmod +x sample_enc_vc1

执行

./sample_enc_vc1

在这里插入图片描述
根据提示我们输入:

./sample_enc_vc1 -v …/…/…/…/vc1-720-480.yuv -o my.vc1 -w 720 -h 480 -I420

编码后出现my.vc1,我们用mediainfo查看编码后的文件:
在这里插入图片描述
说明编码好了,如果想要更近一步了解,可以查看samples中的encoder/sample_enc_vc1/sample_enc_vc1.cpp:

从下图可以看出,对w,h有要求:
在这里插入图片描述
从下图可以看到,命令行其实还有很多其它选项:

在这里插入图片描述

想要更加详细的,可以查看下面代码:

/*
 Copyright (c) 2023 MainConcept GmbH or its affiliates.  All rights reserved.


 MainConcept and its logos are registered trademarks of MainConcept GmbH or its affiliates.
 This software is protected by copyright law and international treaties.  Unauthorized
 reproduction or distribution of any portion is prohibited by law.
 */

#include <stdio.h>
#include <stdlib.h>

#include "mctypes.h"
#include "mcfourcc.h"
#include "bufstrm.h"
#include "sample_common_args.h"
#include "sample_common_misc.h"

#include "buf_file.h"

#include "enc_vc1.h"
#include "enc_vc1_def.h"

#include "config_vc1.h"

const char * profile_names[] = {"Simple", "Main", "Reserved", "Advanced"};
const char * interlace_names[] = {"Progressive", "Field picture", "MBAFF", "PAFF"};
const char * ratectl_names[] = {"Const quant", "VBR", "CBR"};

// guess desired video_type
int get_video_type(int width, int height, double frame_rate)
{
    if ((width == 352) && ((height == 240) || (height == 288)))
    {
        return VC1_CIF;
    }
    else if ((width == 480) && ((height == 480) || (height == 576)))
    {
        return VC1_SVCD;
    }
    else if ((width == 720) && ((height == 480) || (height == 576)))
    {
        return VC1_D1;
    }
    else if (width < 288)
    {
        return VC1_BASELINE;
    }
    else if (width >= 1280)
    {
        return VC1_BD;
    }

    return VC1_MAIN;
}


int main(int argc, char* argv[])
{
    vc1_param_set param_set;
 
    struct vc1_v_settings * v_settings = &param_set.params;
    vc1venc_tt * v_encoder = NULL;

    unsigned char * input_video_buffer = NULL;

    bufstream_tt * videobs = NULL;

    char * in_file;
    char * out_file;

    char * cfg_file;

    int32_t width;
    int32_t height;
    int32_t fourcc;

    double  frame_rate;
    int32_t bit_rate;
    int32_t interlaced;

    int32_t perf_preset;

    arg_item_t params[] =
    {
        { IDS_VIDEO_FILE,    1,  &in_file},
        { IDS_OUTPUT_FILE,   1,  &out_file},
        { IDS_CONFIG_FILE,   0,  &cfg_file},
        { IDI_V_WIDTH,       1,  &width},
        { IDI_V_HEIGHT,      1,  &height},
        { IDN_V_FOURCC,      1,  &fourcc},
        { IDD_V_FRAMERATE,   0,  &frame_rate},
        { IDI_BITRATE,       0,  &bit_rate},
        { IDN_V_INTERLACED,  0,  &interlaced},
        { IDI_V_PERFORMANCE, 0,  &perf_preset}
    };

    int init_options = 0;
    void * opt_list[10];

    if (parse_args(argc - 1, argv + 1, sizeof(params) / sizeof(params[0]), params) >= 0)
    {
        int line_size, img_start;
        int video_frame_size = get_video_frame_size(width, height, fourcc, &line_size, &img_start);
        int video_type = get_video_type(width, height, frame_rate);

        vc1OutVideoDefaults(v_settings, video_type, 0);

        if (cfg_file)
        {
            APIEXTFUNC_LOADPARAMSET load_param_func = (APIEXTFUNC_LOADPARAMSET) VC1ConfigGetAPIExt(MCAPI_LoadParamSet);

            if (load_param_func(&param_set, cfg_file) != MCAPI_NOERROR)
            {
                printf("\nInvalid config file. Terminating...\n");
                return 0;
            }
        }


        v_settings->min_key_frame_interval   = 1;

        v_settings->bit_rate                 = bit_rate >= 0 ? bit_rate * 1000 : v_settings->bit_rate;
        v_settings->frame_rate               = frame_rate > 0.0 ? frame_rate : v_settings->frame_rate;
        v_settings->interlace_mode           = interlaced == 0 ? VC1_PROGRESSIVE : interlaced == 1 ? VC1_INTERLACE_MBAFF : v_settings->interlace_mode;

        // the encoder can't scale the picture
        v_settings->def_horizontal_size      = width;
        v_settings->def_vertical_size        = height;

        if (vc1OutVideoChkSettings(NULL, v_settings, VC1_CHECK_AND_ADJUST, NULL) == VC1ERROR_FAILED)
        {
            printf("\nInvalid settings, vc1OutVideoChkSettings failed. Terminating...\n");
            return 0;
        }

        printf(
            "\nVC-1 %s Profile @ Level%d, %s, %s @ %.1f kbit/s, GOP %d/%d\n",
            profile_names[v_settings->profile_id],
            v_settings->level_id,
            interlace_names[v_settings->interlace_mode],
            ratectl_names[v_settings->bit_rate_mode],
            v_settings->bit_rate / 1000.0,
            v_settings->key_frame_interval,
            v_settings->b_frame_distance);

        if (perf_preset >= 0 && perf_preset <= 15)
            vc1OutVideoPerformance(v_settings, 0, perf_preset, 0);

        v_encoder = vc1OutVideoNew(NULL, v_settings, 0, 0xFFFFFFFF, 0, 0);
        
        if(!v_encoder)
        {
            printf("vc1OutVideoNew failed\n");
            return 0;
        }

        videobs = open_file_buf_write(out_file, 65536, NULL);

        // save original auxinfo handler
        org_auxinfo = videobs->auxinfo;

        // in order to get encoding statistics
        videobs->auxinfo = auxinfo;

        if(vc1OutVideoInit(v_encoder, videobs, init_options, &opt_list[0]))
        {
            printf("vc1OutVideoInit fails.\n");
            return 0;
        }

        input_video_buffer = new unsigned char [video_frame_size];

        FILE * input_video_file = fopen(in_file, "rb");
        
        int aborted = 0;
        int frame_cnt = 0;

        const void * ext_info_stack[16] = {0};

        while (1)
        {
            unsigned int option_flags = 0;
            unsigned int option_cnt = 0;
            const void ** ext_info = &ext_info_stack[0];

            if (fread(input_video_buffer, sizeof(unsigned char), video_frame_size, input_video_file) != video_frame_size)
            {
                // end of the file
                break;
            }


            if (vc1OutVideoPutFrame(v_encoder, input_video_buffer + img_start, line_size, width, height, fourcc, option_flags, ext_info))
            {
                break;
            }

            frame_cnt++;

            if(has_pressed_key(NULL)){
                aborted = 1;
                break;
            }
        }

        if (v_encoder)
        {
            vc1OutVideoDone(v_encoder, aborted);
            vc1OutVideoFree(v_encoder);
        }

        if (videobs)
        {
            videobs->done(videobs, aborted);
            videobs->free(videobs);
        }

        if (input_video_buffer)
            delete [] input_video_buffer;

        if (input_video_file)
            fclose(input_video_file);
    }

  return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/535696.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

kubeadm方式搭建的k8s集群升级——2023.05

文章目录 一、概述二、集群概况三、升级集群2.1 确定升级版本2.2 升级Master2.3 升级 Worker 四、验证集群 一、概述 搭建k8s集群的方式有很多种&#xff0c;比如二进制&#xff0c;kubeadm&#xff0c;RKE&#xff08;Rancher&#xff09;等&#xff0c;k8s集群升级方式也各有…

利用android studio 生成 JNI需要的动态库so文件 图文详解

一、环境搭建 1.1 Android studio2021.2.1安装 到官网下载&#xff0c;此处不再陈述 1.2 JNI安装 JNI 是JDK里的内容&#xff0c;电脑上正确安装并配置JDK即可。 1.3 NDK安装 直接在Android studio下载&#xff08;File---->Settings&#xff09; 1.4 编译工具 工具一…

72.建立一个表格组件

本节课我们将实现如下的表格&#xff1a; ● 首先&#xff0c;我们直接用表格元素将这些数据展现出来 <table><tr><td>Chair</td><td>The Laid Back</td><td>The Worker Bee</td><td>The Chair 4/2</td></tr…

数据结构与算法——算法与算法分析

算法与算法分析 初识算法算法的定义算法的描述算法与程序算法的特性算法设计的要求 算法时间效率的度量事前估计法算法时间复杂度的渐进表示法算法时间复杂度案例分析最好、最坏和平均时间复杂度算法的空间复杂度 初识算法 算法的定义 算法&#xff0c;即是对特定问题求解方法…

Winform实现以管理员模式启动并实现修改系统时间

场景 SpringBoot/Java中定时请求并根据服务端响应头的date实现本地Windows修改时间/时间同步(管理员权限问题-bat管理员启动cmd并运行jar)&#xff1a; SpringBoot/Java中定时请求并根据服务端响应头的date实现本地Windows修改时间/时间同步(管理员权限问题-bat管理员启动cmd…

在家吃灰老主机怎么自建黑群晖NAS当影音服务器

准备:u盘一个,老主机一个,要显示器键盘,烧u盘软件win32-disk(网上找)、balena(balenaEtcher - Flash OS images to SD cards & USB drives)的 1,巴西大佬的引导文件 进来这里 GitHub - fbelavenuto/arpl: Automated Redpill Loader 点右边的release文件下载 下载…

golang 函数调用栈笔记

一个被函数在栈上的情况&#xff1a;&#xff08;栈从高地址向低地址延伸&#xff09; 返回地址&#xff08;函数执行结束后&#xff0c;会跳转到这个地址执行&#xff09; BP&#xff08;函数的栈基&#xff09;局部变量返回值&#xff08;指的是函数返回值&#xff0c;eg&am…

Facebook广告投放过程中,如何提高有效曝光?

在数字营销中&#xff0c;广告曝光是至关重要的一环&#xff0c;Facebook广告投放也不例外。 有效曝光能够提高广告的点击率和转化率&#xff0c;从而帮助企业实现更好的广告效果。那么在Facebook广告投放过程中&#xff0c;如何提高有效曝光呢&#xff1f;下面将为大家分享几…

【Mybatis】SpringBoot整合Mybatis

唠嗑部分 之前我们说了Mybatis的一些文章&#xff0c;相关文章&#xff1a; 【Mybatis】简单入门及工具类封装-一 【Mybatis】如何实现ORM映射-二 【Mybatis】Mybatis的动态SQL、缓存机制-三 【Mybatis】Mybatis处理一对多、多对多关系映射-四 这篇文章我们来说说SpringBoot如…

前端面试高频题精讲(一)

HTML篇 什么是语义化 用正确的标签做正确的事情。例如&#xff1a;段落用 p 标签&#xff0c;标题用 h 系列标签。 便于团队的开发和维护&#xff0c;我见过用div走天下的&#xff0c;但不利于看清页面结构。在没有加载 CSS 的情况下也能呈现较好的内容结构与代码结构&#xf…

Ubuntu18.04/20.04/22.04的Apollo8.0软件包安装(免编译)

本文主要介绍在如何使用软件包&#xff08;即 deb 包&#xff09;的方式来安装 Apollo&#xff0c;相对于源码方式安装&#xff0c;软件包安装方式不需要编译&#xff0c;更加快捷。但是对环境的支持比较单一&#xff0c;如果在自定义环境内安装&#xff0c;请移步源码安装方式…

camunda流程引擎connector如何使用

在 Camunda 中&#xff0c;Connector 是一种用于与外部系统或服务交互的机制。它允许 BPMN 模型中的 Service Task 节点与外部系统或服务进行通信&#xff0c;从而使流程更加灵活和可扩展。使用 Connector&#xff0c;可以将业务流程与外部系统集成在一起&#xff0c;而无需编写…

java商城 java电子商务Spring Cloud+Spring Boot+mybatis+MQ+VR全景+b2b2c

一个好的SpringCloudSpringBoot b2b2c 电子商务平台涉及哪些技术、运营方案&#xff1f;以下是我结合公司的产品做的总结&#xff0c;希望可以帮助到大家&#xff01; 搜索体验小程序&#xff1a;海哇 1. 涉及平台 平台管理、商家端&#xff08;PC端、手机端&#xff09;、买家…

Python学习27:存款买房(A)

描述‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬ 你刚刚大学毕业&#xff0c;…

亚马逊如何提高商品listing转化率?测评自养号优势和技巧有哪些?

之前有讲过&#xff0c;亚马逊店铺流量的几大入口&#xff0c;如何获取流量。那么获取了流量之后&#xff0c;亚马逊卖家就需要考虑到转化率的问题&#xff0c;如果流量来没有转化率&#xff0c;一样不会产生订单。如果转化率太低还会影响到商品的表现&#xff0c;比如排名会下…

亚马逊云科技基础设施为大型模型推理提供技术保障

在2019年的亚马逊云科技re:Invent上&#xff0c;亚马逊云科技发布了新的基础设施Inferentia芯片和Inf1实例。Inferentia是一种高性能机器学习推理芯片&#xff0c;由亚马逊云科技定制设计&#xff0c;其目的是提供具有成本效益的大规模低延迟预测。时隔四年&#xff0c;2023年4…

使用particles动态粒子效果,优化登录页

前言 书接上回&#xff0c;咱不是做了落日余晖登录页&#xff0c;说白了就是一个背景图&#xff0c;感觉需要进一步优化一下&#xff0c;做一个高大上的效果。所图所示&#xff0c;我想要背后的动态粒子效果&#xff0c;这就开搞&#xff0c;基于老的代码&#xff1a;vue2和el…

10种最常用的3D 分析工具【GIS】

3D 分析一直是 GIS 中的一个增长趋势&#xff0c;因为它可以更好地表示现实世界。 这不仅仅是为了一张漂亮的图片。 对于某些类型的问题&#xff0c;3D 分析有时是你解决问题的唯一方法。 推动这一需求的 3D 数据类型也呈爆炸式增长。 例如&#xff0c;激光雷达、BIM、无人机…

S7-200SMART 实现MODBUS TCP通信的具体方法示例(客户端读写+服务器响应)

S7-200SMART 实现MODBUS TCP通信的具体方法示例(客户端读写+服务器响应) 前面和大家介绍了MODBUS TCP的基本使用方法,具体可参考以下链接中的内容: S7-200SMART实现MODBUS TCP通信(客户端+服务器)的具体方法和步骤示例 本次继续和大家分享S7-200SMART 中实现MODBUS TCP通…

界面控件DevExtreme使用指南 - 如何为雷达图添加注释?

在之前的版本中&#xff0c;官方技术团队为DevExtreme图表引入了注释支持。在v20.1版本中&#xff0c;继续扩展了对Polar Chart&#xff08;雷达图&#xff09;注释的支持&#xff0c;现在可以根据需要应用文本、图像或自定义注释。创建注释后&#xff0c;可以将其附加到Polar …