一个有趣的vc1编码器

这篇具有很好参考价值的文章主要介绍了一个有趣的vc1编码器。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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

文件包在附件,打开文件夹,可以看到下面三个文件夹:
一个有趣的vc1编码器
因为我们的系统试Linux,所以我们选择Linux(x64).

继续打开,可以看到以下文件夹:
一个有趣的vc1编码器

cd bin

一个有趣的vc1编码器

chmod +x sample_enc_vc1

执行

./sample_enc_vc1

一个有趣的vc1编码器
根据提示我们输入:

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

编码后出现my.vc1,我们用mediainfo查看编码后的文件:
一个有趣的vc1编码器
说明编码好了,如果想要更近一步了解,可以查看samples中的encoder/sample_enc_vc1/sample_enc_vc1.cpp:

从下图可以看出,对w,h有要求:
一个有趣的vc1编码器
从下图可以看到,命令行其实还有很多其它选项:

一个有趣的vc1编码器

一个有趣的vc1编码器

想要更加详细的,可以查看下面代码:文章来源地址https://www.toymoban.com/news/detail-448186.html

/*
 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;
}

到了这里,关于一个有趣的vc1编码器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • STM32一个定时器同时配置编码器和PWM输出时PWM无法正常输出的原因【避坑】

             最近我在做写代码的时候,因为定时器的资源紧张,就在一个定时器上同时配置了编码器和PWM,发现PWM无法正常输出,查了很久发现网上资料不多,在仔细翻阅手册研究后才发现是 时钟信号 的问题。 具体原因 定时器在设置编码器模式后,计数的时钟源就会变成编

    2024年02月04日
    浏览(40)
  • 编码器 | 基于 Transformers 的编码器-解码器模型

    基于 transformer 的编码器-解码器模型是 表征学习 和 模型架构 这两个领域多年研究成果的结晶。本文简要介绍了神经编码器-解码器模型的历史,更多背景知识,建议读者阅读由 Sebastion Ruder 撰写的这篇精彩 博文。此外,建议读者对 自注意力 (self-attention) 架构 有一个基本了解

    2024年02月08日
    浏览(50)
  • 【FPGA】Verilog:编码器 | 实现 4 到 2 编码器

    0x00 编码器(Encoder) 编码器与解码器相反。当多台设备向计算机提供输入时,编码器会为每一个输入生成一个与设备相对应的信号,因此有多少比特就有多少输出,以数字形式表示输入的数量。 例如,如果有四个输入,就需要一个两位二进制数来表示 0 至 3,这样就有四个输

    2024年02月04日
    浏览(42)
  • 旋转编码器原理、选型及编码

    旋转编码器(rotary encoder)也称为轴编码器,是将旋转的机械位移量转换为电气信号,对该信号进行处理后检测位置速度等信号的传感器。检测直线机械位移量的传感器称为线性编码器[1]。一般装设在旋转物体中垂直旋转轴的一面。 旋转编码器用在许多需要精确旋转位置及速

    2024年01月19日
    浏览(30)
  • AE(自动编码器)与VAE(变分自动编码器)的区别和联系?

    他们各自的概念看以下链接就可以了:https://blog.csdn.net/weixin_43135178/category_11543123.html  这里主要谈一下他们的区别? VAE是AE的升级版,VAE也可以被看作是一种特殊的AE AE主要用于数据的 压缩与还原 ,VAE主要用于 生成 。 AE是将数据映直接映射为数值 code(确定的数值) ,而

    2024年02月03日
    浏览(38)
  • 解码器 | 基于 Transformers 的编码器-解码器模型

    基于 transformer 的编码器-解码器模型是 表征学习 和 模型架构 这两个领域多年研究成果的结晶。本文简要介绍了神经编码器-解码器模型的历史,更多背景知识,建议读者阅读由 Sebastion Ruder 撰写的这篇精彩 博文。此外,建议读者对 自注意力 (self-attention) 架构 有一个基本了解

    2024年02月08日
    浏览(40)
  • FPGA VHDL文本编辑器设计8-3优先编码器并构成16-4优先编码器

    题目要求: 在文本编辑器中使用VHDL语言设计一个优先8-3编码器。在另一个新实体中将其定义成一个元件,通过元件例化的方式设计一个16-4优先编码器。文件命名为***164.vhd,器件设定为EP3C16F256C8。要求输入节点命名为d0…d15,低电平有效;输出节点命为A、B、C、D。进行波形仿

    2024年02月11日
    浏览(36)
  • STM32编码器模式(带方向/正交编码)

    看前说明 :这里重点介绍的时STM32的定时器编码器模式,是根据STMF10x参考手册,如果有使用过编码器或编码器不一样的可以直接跳过前面的编码器介绍,直接看理论分析与程序部分。 这里需要注意的参数 输出脉冲线数:1024线: 编码器每旋转一周输出的脉冲的个数 ,这个数

    2023年04月24日
    浏览(43)
  • 【单片机】STM32单片机读取旋转编码器,TIM定时器编码器模式捕获,程序

    旋转编码器简单来说,就是会输出2个PWM,依据相位可以知道旋转方向,依据脉冲个数可以知道旋转的角度。一般旋转一圈有一个固定数值的脉冲个数。 旋转编码器广泛用于电机、或者角度传感器,STM32的定时器可以直接接入这两个波形获取到信息。 前两个引脚(接地和Vcc)

    2024年02月13日
    浏览(35)
  • 编码器的分类

    目录 光电编码器 一、增量式编码器 二、绝对式编码器 三、混合式绝对值编码器 四、旋转变压器 五、正余弦伺服电机编码器         光电编码器主要有增量式编码器、绝对式编码器、混合式绝对值编码器、旋转变压器、正余弦伺服电机编码器等,其中增量式编码器、绝

    2024年02月05日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包