ffmpeg: how to save h264 raw data as mp4 file

混江龙づ霸主 提交于 2020-01-22 16:07:06

问题


I encode h264 data by libavcodec. ex.

while (1) {
  ...
  avcodec_encode_video(pEnc->pCtx, OutBuf, ENC_OUTSIZE, pEnc->pYUVFrame);
  ...
}

If I directly save OutBuf data as a .264 file, it can`t be play by player. Now I want to save OutBuf

as a mp4 file. Anyone know how to do this by ffmpeg lib? thanks.


回答1:


You use avformat_write_header, av_interleaved_write_frame, avformat_write_trailer and friends.

Their usage is shown in the muxing example of FFmpeg.

See a similar topic: Raw H264 frames in mpegts container using libavcodec with also writing to a file (different container, same API)

See also links from answer here: FFMpeg encoding RGB images to H264



来源:https://stackoverflow.com/questions/14341262/ffmpeg-how-to-save-h264-raw-data-as-mp4-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!