问题
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