Reputation: 1822
I am using FFmpeg to write a mp4 file, I grab bitmap images from remote IP camera and encode it by h.264, the media container is mp4 file, no problem to generate the MP4 file if I only record several minutes, the problem is FFmpeg never flushs buffer data to disk when I call method av_interleaved_write_frame
(all encoded data in memory, never free them), only when I call method avio_close(oc->pb);
, it will flush all encoded data to disk, I tried to call method avcodec_flush_buffers
every time after calling av_interleaved_write_frame
, but no effect. I am newbie to FFmpeg, if you are familiar with FFmpeg, please help me.
thanks in advance.
Sean
Upvotes: 1
Views: 4910
Reputation: 1
Another suggestion (it worked just well in my case) is to call with NULL AVPacket pointer:
av_interleaved_write_frame(AVFormatContext*, NULL);
then it flushes whatever stream it has in the buffer.
Upvotes: 0
Reputation: 1822
I got the problem, that was caused by I never write audio frame, so if just want to encode several bmps to a video file, please note:
1) don't add audio stream(add_stream). 2) don't open audio stream(open_audio).
hope this also helps others.
Sean
Upvotes: 1