<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: huazhusun</title>
    <description>The latest articles on DEV Community by huazhusun (@huazhusun).</description>
    <link>https://dev.to/huazhusun</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1116571%2F7563bc2b-ad00-49fa-a190-42d4985ca0e2.png</url>
      <title>DEV Community: huazhusun</title>
      <link>https://dev.to/huazhusun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/huazhusun"/>
    <language>en</language>
    <item>
      <title>How can I set the ffmpeg ffcoder attributes?</title>
      <dc:creator>huazhusun</dc:creator>
      <pubDate>Mon, 10 Jul 2023 03:29:03 +0000</pubDate>
      <link>https://dev.to/huazhusun/how-can-i-set-the-ffmpeg-ffcoder-attributes-29ma</link>
      <guid>https://dev.to/huazhusun/how-can-i-set-the-ffmpeg-ffcoder-attributes-29ma</guid>
      <description>&lt;p&gt;I just write a ffcodec for ffmpeg. It can run success with my test codes, and also with ffmpeg test. However , when I tried use it in chrome, it run with some errors as following: [3845:3880:0710/110530.508867:ERROR:ffmpeg_video_decoder.cc(487)] avcodec_open2 failed.-558323010&lt;br&gt;
[3845:3880:0710/110530.509921:ERROR:ffmpeg_video_decoder.cc(491)] avcodec_open2 error: Internal bug, should not have happened.&lt;/p&gt;

&lt;p&gt;belowing is my ffcodec options for my decoder, can someone give some advice?:&lt;/p&gt;

&lt;h1&gt;
  
  
  define OFFSET(x) offsetof(OMXCodecDecoderContext, x)
&lt;/h1&gt;

&lt;h1&gt;
  
  
  define VDE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM
&lt;/h1&gt;

&lt;h1&gt;
  
  
  define VE  AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
&lt;/h1&gt;

&lt;h1&gt;
  
  
  define VD  AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
&lt;/h1&gt;

&lt;p&gt;static const AVOption options[] = {&lt;br&gt;
    { "omx_libname", "OpenMAX library name", OFFSET(libname), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },&lt;br&gt;
    { "omx_libprefix", "OpenMAX library prefix", OFFSET(libprefix), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },&lt;br&gt;&lt;br&gt;
    { "profile",  "Set the Decoding profile", OFFSET(profile), AV_OPT_TYPE_INT,   { .i64 = FF_PROFILE_UNKNOWN },       FF_PROFILE_UNKNOWN, FF_PROFILE_H264_HIGH, VE, "profile" },&lt;br&gt;
    { "baseline", "",                         0,               AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_BASELINE }, 0, 0, VE, "profile" },&lt;br&gt;
    { "main",     "",                         0,               AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_MAIN },     0, 0, VE, "profile" },&lt;br&gt;
    { "high",     "",                         0,               AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_HIGH },     0, 0, VE, "profile" },&lt;br&gt;
    { NULL }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;static const AVCodecHWConfigInternal *const omx_hw_configs[] = {&lt;br&gt;
    &amp;amp;(const AVCodecHWConfigInternal) {&lt;br&gt;
        .public          = {&lt;br&gt;
            .pix_fmt     = AV_PIX_FMT_NV12,&lt;br&gt;
            .methods     = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |&lt;br&gt;
                           AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,&lt;br&gt;
            .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,&lt;br&gt;
        },&lt;br&gt;
        .hwaccel         = NULL,&lt;br&gt;
    },&lt;br&gt;
    NULL&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;static const AVOption ff_omxcodec_vdec_options[] = {&lt;br&gt;
    { "delay_flush", "Delay flush until hw output buffers are returned to the decoder",&lt;br&gt;
                     OFFSET(delay_flush), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD },&lt;br&gt;
    { NULL }&lt;br&gt;
};&lt;/p&gt;

&lt;h1&gt;
  
  
  define DECLARE_OMX_VCLASS(short_name)                   \
&lt;/h1&gt;

&lt;p&gt;static const AVClass ff_##short_name##_omxcodec_dec_class = { \&lt;br&gt;
    .class_name = #short_name "_libomxh264",                    \&lt;br&gt;
    .item_name  = av_default_item_name,                         \&lt;br&gt;
    .option     = ff_omxcodec_vdec_options,                   \&lt;br&gt;
    .version    = LIBAVUTIL_VERSION_INT,                        \&lt;br&gt;
};&lt;/p&gt;

&lt;h1&gt;
  
  
  define DECLARE_OMX_VDEC(short_name, full_name, codec_id, bsf)                          \
&lt;/h1&gt;

&lt;p&gt;DECLARE_OMX_VCLASS(short_name)                                                          \&lt;br&gt;
const FFCodec ff_ ## short_name ## &lt;em&gt;omx_decoder = {                                     \&lt;br&gt;
    .p.name         = #short_name "_omxcodec",                                               \&lt;br&gt;
    CODEC_LONG_NAME(full_name " OpenMAX IL decoder"),                                  \&lt;br&gt;
    .p.type         = AVMEDIA_TYPE_VIDEO,                                                      \&lt;br&gt;
    .p.id           = codec_id,                                                                \&lt;br&gt;
    .p.priv_class   = &amp;amp;ff&lt;/em&gt;##short_name##_omxcodec_dec_class,                                 \&lt;br&gt;
    .priv_data_size = sizeof(OMXCodecDecoderContext),                                        \&lt;br&gt;
    .init           = omx_decode_init,                                                  \&lt;br&gt;
    FF_CODEC_DECODE_CB(omx_decode_frame),                                       \&lt;br&gt;
    .close          = omx_decode_end,&lt;br&gt;&lt;br&gt;
    .flush          = omx_decode_flush,                                    \&lt;br&gt;
    .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \&lt;br&gt;
    .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE |                                       \&lt;br&gt;
                      FF_CODEC_CAP_SETS_PKT_DTS,                                               \&lt;br&gt;
    .bsfs           = bsf,                                                                     \&lt;br&gt;
    .hw_configs     = omx_hw_configs,                                                   \&lt;br&gt;
    .p.wrapper_name = "omxcodec",                                                            \&lt;br&gt;
};   **&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
