0

I want to merge two videos (as example the iphone video from https://peach.blender.org/trailer-page/). The videos are placed on an background image with the overlay filter and the second video starts 3 seconds later.

And I need that the audio is mixed.

Here is my code:

ffmpeg \
    -loop 1 -i background.png  \
    -itsoffset 0  -i trailer_iphone.m4v \
    -itsoffset 3  -i trailer_iphone.m4v \
    \
    -y \
    -t 36 \
    -filter_complex "
        [2:a] adelay=3000 [2delayed];
        [1:a][2delayed] amerge=inputs=2 [audio];
        [0][1:v] overlay=10:10:enable='between(t,0,33)' [lv1];
        [lv1][2:v] overlay=10:300:enable='between(t,0,36)' [video]
    " \
    \
    -threads 0 \
    -map "[video]" -map "[audio]" \
    -vcodec libx264 -acodec aac \
    merged-video.mp4

I get the error message:

[Parsed_overlay_3 @ 0x7fe892502ac0] [framesync @ 0x7fe892502b88] Buffer queue overflow, dropping.

And the merged video has many dropped frames.

I know that are some other posting with this error message. But the suggested solutions doesn't work for me.

How can I fix the problem?

2
  • What suggested solutions have you tried? Commented Sep 19, 2016 at 14:02
  • I tried setpts=PTS-STARTPTSfor the audio channels, but the result was the same. Commented Sep 20, 2016 at 6:58

1 Answer 1

5

FFmpeg is dropping frames from [2:v] because the processing of [0][1:v]overlay is taking longer than the frame drop threshold.

Insert a fifo filter to 2:v to avoid this.

ffmpeg -loop 1 -i background.png
       -itsoffset 0 -i trailer_iphone.m4v
       -itsoffset 3 -i trailer_iphone.m4v
       -t 36 -filter_complex
         "[2:a]adelay=3000[2delayed];[1:a][2delayed]amerge=inputs=2[audio];
          [0][1:v]overlay=10:10:enable='between(t,0,33)'[lv1];
          [2:v]fifo[2f];[lv1][2f]overlay=10:300:enable='between(t,0,36)'[video]"
       -threads 0 -map "[video]" -map "[audio]" -vcodec libx264 -acodec aac merged-video.mp4

(For stereo audio, it should be adelay=3000|3000)

Sign up to request clarification or add additional context in comments.

7 Comments

It works great. Thank you! I never used the fifo-filter before.
Thanks for the explanation ("the processing of [0][1:v]overlay is taking longer than the frame drop threshold"), it really helped. I ran into this error when generating a GIF. The fix was to generate the palette in a separate command before using the palette to generate the GIF.
For GIF, it can be done in a single command with a FIFO filter after the palettegen.
@Mulvya I tried that, but fifo wouldn't accept the output of palettegen (probably because that output is a picture, not a video). I can't remember the exact error message off the top of my head though.
FWIW I had to do it again, and this time I figured it out. The fifo filter has to go after the split filter, between the video stream and the paletteuse filter which consumes that video. The fifo filter only accepts one stream, so you have to be sure only the video stream is getting passed to fifo, not the output from paletteuse. E.g. split[x][z];[z]palettegen[y];[x]fifo[a];[a][y]paletteuse
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.