How to encode H.264 video using FFmpeg C API and then open the output with a media player?

后端 未结 2 1265
忘掉有多难
忘掉有多难 2021-02-10 00:51

I\'m trying to encode a H.264 video with the FFMPEG C API. I have successfully compiled and executed the decoding/encoding example provided by FFMPEG.

The problem I\'m f

相关标签:
2条回答
  • 2021-02-10 01:16

    Your problem probably is not encoding itself but the fact that you output raw H.264 stream (I suppose you used AnnexB format) without any muxing. Most of players expect H.264 in some container (like MKV, MP4 or FLV) and do not support playing of raw H.264 streams. For players using DirectShow filters (like MPC-HC / WMP) it also needs raw H.264 AnnexB demuxer before decoder. Try to mux this output to MKV with MKVToolnix and test resulting file.

    0 讨论(0)
  • 2021-02-10 01:24

    As mentioned by nobody555, maybe your VLC simply cannot open that file because it is a raw stream.

    Alternatives are listed at: https://superuser.com/questions/261774/converting-or-playing-a-264-video-file

    ffplay is an option, but it also works on VLC 2.2.1, Ubnuntu 15.10.

    Also consider the example: https://github.com/FFmpeg/FFmpeg/blob/n3.0/doc/examples/muxing.c which generates a container format instead of a raw stream.

    0 讨论(0)
提交回复
热议问题