Concatenating video clip with static image causes buffer errors

I'm trying to concatenate a 15 second clip of a video (MOVIE.mp4) with 5 seconds (no audio) of an image (IMAGE.jpg) using FFmpeg.

Something seems to be wrong with my filtergraph, although I'm unable to determine what. The command I've put together is the following:

ffmpeg \
-loop 1 -t 5 -I IMAGE.jpg \
-t 15 -I MOVIE.mp4 \
-filter_complex "[0:v]scale=480:640[1_v];anullsrc[1_a];[1:v][1:a][1_v][1_a]concat=n=2:v=1:a=1[out]" \
-map "[out]" \
-strict experimental tst_full.mp4

Unfortunately, this seems to be creating some strange results:

  1. On my personal computer (FFmpeg 4.2.1) it correctly concatenates the movie with the static image; however, the static image lasts for an unbounded length of time. (After entering ctrl-C, the movie is still viewable, but is of an extremely long length--e.g., 35 min--depending on when I interrupt the process.)

  2. On a remote machine where I need to do the ultimate video processing (FFmpeg 2.8.15-0ubuntu0.16.04.1), the command does not terminate, and instead, I get cascading errors of the following form:

Past duration 0.611458 too large
[output stream 0:0 @ 0x21135a0] 100 buffers queued in output stream 0:0, something may be wrong.
[output stream 0:0 @ 0x21135a0] 100000 buffers queued in output stream 0:0, something may be wrong.

I haven't been able to find much documentation that elucidates what these errors mean, so I don't know what's going wrong.

1 answer

  • answered 2020-02-15 01:14 drake7

    Don't use anullsrc in the filterchain. Make it a 3rd input:

    ffmpeg -t 15 -i "MOVIE.mp4" \
    -loop 1 -t 5 -i "IMAGE.jpg" \
    -f lavfi -t 5 -i anullsrc \
    -filter_complex "\
    [0_v][0:a][scaledImageVideo][2:a]concat=n=2:v=1:a=1[v][a]" \
    -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" tst_full.mp4

    scale2ref always makes your image the same size as the video.