When I transcode this source file with ffmpeg,ffmpeg may eat up a lot of memory about dozens of GB till to be killed,Why?
the report here:
ffmpeg started on 2017-12-19 at 10:59:15
Report written to "ffmpeg-20171219-105915.log"
Command line:
ffmpeg -i memory_error_fifo.mp4 -s 854x480 -vcodec libx264 -x264opts
"keyint=50" -b:v 238k -vf "movie=namei.jpg [watermark]; [vf0] fifo
[vf1];[vf1][watermark] overlay=main_w-overlay_w-0:0[vf2]" -acodec
libfdk_aac -ar 44100 -movflags faststart -f mp4 output.mp4 -y -v trace
-report
ffmpeg version N-89095-gb3c1172 Copyright (c) 2000-2017 the FFmpeg
How to reproduce:
ffmpeg -i "memory_error_fifo.mp4" -s 854x480 -vcodec libx264 -x264opts
keyint=50 -b:v 238k -vf "movie=namei.jpg [watermark]; [vf0] fifo
[vf1];[vf1][watermark] overlay=main_w-overlay_w-0:0[vf2]" -acodec
libfdk_aac -ar 44100 -movflags faststart -f mp4 output.mp4 -y -v trace
-report
When i use -an to disable audio,the result is ok; when i not use "fifo",the result is ok,but my project needed this "fifo" filter.
n3.5-dev-1292-gce001bb with master commit
ce001bb8fc6677541c401a614e05e5058d58dde1
built on linux
ffmpeg report:https://pan.baidu.com/s/1qYNvTes
attached source file: https://pan.baidu.com/s/1pLzbwbp
Reason: The fifo-filter won't output frames until it is being requested. And ffmpeg only requests frames which belongs to the stream with a smallest timestamp (See the choose_output() function). So when the media has some abnormal contents, like a short piece of pure image without audio or some audio decoding errors, ffmpeg will remain requesting audio frames and leave thousands of video frames blocked in the fifo-filter eating up your memory.
Solution: I met the same problem and solved it by adding a limitation of samples in the fifo-filter. It will force the next linked filter to request frames when the number of buffered frames exceeds limitation. Code:
I'm not sure if these changes will cause some other problems. If someone has a better solution, let me know please.