FFmpeg avcodec_find_encoder问题

net*_*net 7 ffmpeg

我是ffmpeg的新手.

我的问题是" avcodec_find_encoder(CODEC_ID_H264);" func总是返回null.

ffmpeg configure在我的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
Run Code Online (Sandbox Code Playgroud)

如您所见,配置包含--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
Run Code Online (Sandbox Code Playgroud)

谢谢

小智 12

打电话avcodec_register_all()给我解决了.

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


小智 1

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