4

任何人都可以从这个FFMPEG 教程示例中生成可读的 H264 文件吗?我唯一改变的是第 350 行的输出格式:

avformat_alloc_output_context2(&oc, NULL, "h264", filename);

使用 FFMPEG 1.0.1+libx64 v129 运行它会生成一个 6MB 的.3gp文件,大多数播放器(包括 VLC)都无法读取该文件。当我加载它时,我可以看到它包含所有帧,我可以成功解码和查看它们,但由于某种原因,大多数玩家将无法打开它。

有没有人更成功?

4

1 回答 1

3

The output format should refer to the container, not the codecs used. What you are doing is equivalent to encoding (on the commandline) to a filename with ".h264" extension. This will produce a raw H.264 file (no container). Many players should be able to handle this, but may not be able to probe it, they would rely on the extension to figure out what it is. If you have a raw file which is saved with .3gp extension, that will fail. Try setting the format to ".3gp" or better yet, leave format NULL as well and let ffmpeg guess from the filename :)

于 2013-01-07T15:27:08.280 回答