0

I am trying to play the video background.mp4 while having another video overlay.mp4 be overlayed in a small rectangle over the background video. The overlay video should be delayed.

By looking up ffmpeg I have build the following command:

ffmpeg -i background.mp4 
       -i overlay.mp4  
       -filter_complex "[1]setpts=PTS-STARTPTS+162/TB, scale=512:288 [over]; 
                        [0][over] overlay=748:412 [outv];
                        [1:a]adelay=162000|162000 [audio];
                        [0:a][audio] amix [outa]" 
       -map "[outv]" 
       -map "[outa]" 
       -codec:v libx264 
       -crf 21 
       -bf 2 
       -flags +cgop 
       -pix_fmt yuv420p 
       output.mp4

This sucessfully merges the videos the way I want. However the overlaid video is stuttering a lot (as in up to 30 second freezes), whereas the background video is playing fine.
The console gives of a lot of messages saying: "Buffer queue overflow, dropping."

I have searched for this online and found, that I should add a fifo buffer. So I tried to:

ffmpeg -i background.mp4 
       -i overlay.mp4  
       -filter_complex "[1]fifo, setpts=PTS-STARTPTS+162/TB, scale=512:288 [over]; 
                        [0][over] overlay=748:412 [outv];
                        [1:a]adelay=162000|162000 [audio];
                        [0:a][audio] amix [outa]" 
       -map "[outv]" 
       -map "[outa]" 
       -codec:v libx264 
       -crf 21 
       -bf 2 
       -flags +cgop 
       -pix_fmt yuv420p 
       output.mp4

However this command never finishes successfully. After going through around 60 seconds of video time it aborts with just the message "Killed".

I presume this is due to a lack of memory even tough I am not sure about that. What do I do now? Any idea on how to successfully overlay the videos, such that the overlaid video has the (at least approximately) same framerate as the background video?

7
  • Share full log.
    – Gyan
    May 30, 2019 at 6:53
  • How do I do that? Per default there is no log. If I add the "-report" option, I get a 4.5 mb file which is too big for pastebin. (There is nothing special when ffmpeg ends, it has just the same lines as all the thousands before: [Parsed_overlay_3 @ 0x55dd294dfaa0] Incoming frame (time:50.6746) from link #0 [libx264 @ 0x55dd296ee0c0] frame=1474 QP=23.51 NAL=2 Slice:B Poc:446 I:0 P:570 SKIP:3030 size=461 bytes [h264 @ 0x55dd29874540] nal_unit_type: 1, nal_ref_idc: 0 [h264 @ 0x55dd298bbee0] nal_unit_type: 1, nal_ref_idc: 2 [h264 @ 0x55dd29865720] nal_unit_type: 1, nal_ref_idc: 0 ) May 30, 2019 at 7:03
  • Upload the report and link to it.
    – Gyan
    May 30, 2019 at 7:38
  • I could upload it here: s000.tinyupload.com/index.php?file_id=03518760727443232425 May 30, 2019 at 7:46
  • Upgrade ffmpeg and try - your version is old. 4.1 is latest.
    – Gyan
    May 30, 2019 at 8:07

0

You must log in to answer this question.

Browse other questions tagged .