问题描述
我通过libavcodec编码h264数据。ex。
while(1){
...
avcodec_encode_video(pEnc- > pCtx,OutBuf,ENC_OUTSIZE,pEnc-> pYUVFrame);
...
}
如果我直接将OutBuf数据保存为。 264文件,它不能播放播放器。现在我想保存OutBuf
作为mp4文件。任何人都知道如何通过ffmpeg lib这样做?谢谢。
您使用 avformat_write_header
, av_interleaved_write_frame
, avformat_write_trailer
和朋友。
他们的用法显示在的FFmpeg。
查看类似的主题:也写入一个文件(不同的容器,相同的API)
另请参阅这里的链接:
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)
See also links from answer here: FFMpeg encoding RGB images to H264
这篇关于ffmpeg:如何将h264原始数据保存为mp4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!