天天看點

ffmpeg 儲存圖檔 将rgb資料_ffmpeg:如何将h264原始資料儲存為mp4檔案

ffmpeg 儲存圖檔 将rgb資料_ffmpeg:如何将h264原始資料儲存為mp4檔案

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.

解決方案

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)