【问题标题】:FFmpeg avcodec_find_encoder problemFFmpeg avcodec_find_encoder 问题
【发布时间】:2011-01-17 01:48:34
【问题描述】:

我是 ffmpeg 的新手。

我的问题是“avcodec_find_encoder(CODEC_ID_H264);” func 总是返回 null。

ffmpeg 配置在我的 ubuntu 系统上。

./ffmpeg
FFmpeg version SVN-r26306, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jan 11 2011 10:34:49 with gcc 4.4.5
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 0 /  0.16. 0
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.92. 0 / 52.92. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.72. 0 /  1.72. 0
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0

如您所见,配置包含 --enable-libx264

所以我认为 avcodec_find_encoder(CODEC_ID_H264);必须返回不为空的东西... 请告诉我如何解决这个问题?

ps) 我在我的程序中调用了 avcodec_init() 和 av_register_all()。

当我编译我的测试程序时,使用下面

gcc -o test test.c -lavutil -lavformat -lavcodec -lx264 -lz -lm

谢谢

【问题讨论】:

    标签: ffmpeg


    【解决方案1】:

    致电avcodec_register_all() 为我解决了这个问题。

    在 Windows 7 上使用 msvc10 和 FFmpeg 版本:2012-11-05 git-c995644

    【讨论】:

    • FFmpeg 版本:2012-11-05 git-c995644
    【解决方案2】:

    经过你的配置,我发现在ffmpeg的启用的编码器中没有包含h264,而在ffmpeg的启用的解码器中包含了h264。也许这就是“avcodec_find_encoder(CODEC_ID_H264)”不起作用的原因。是有线的。

    【讨论】:

    • 启用的编码器:libx264 这来自我的 ./configure - 仍然找不到编码器。
    【解决方案3】:

    确保调用了以下 2 个函数。

      /* must be called before using avcodec lib */
      avcodec_init();
    
      /* register all the codecs */
      avcodec_register_all();
    

    【讨论】:

      猜你喜欢
      • 2020-08-28
      • 2015-06-27
      • 2013-03-25
      • 1970-01-01
      • 2011-09-19
      • 2018-06-21
      • 2012-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多