Search code examples
ffmpegfluent-ffmpeg

ffmpeg complex filter - multiple crops on black background


We are attempting to process a video file by cropping it into several pieces and arranging it on a black background which is exactly 1920x1080. The following command runs but it never completes and we have to kill the process.

Is there something wrong with how we're trying to do this?

ffmpeg -i in.mov -y -filter_complex "\
color=s=1920x1080:c=black[bg];\
[0:v]crop=w=1920:h=ih:x=0:y=0[crop1];\
[0:v]crop=w=iw-1920:h=ih:x=1920:y=0[crop2];\
[bg][crop1]overlay=x=0:y=0[out1];\
[out1][crop2]overlay=x=0:y=h[final]" \
-map [final] out.mov

Solution

  • The color base has no duration set, and so runs indefinitely. The overlay filter by default terminates when the longer input ends. Here, it doesn't. So, let's correct that.

    ffmpeg -i in.mov -y -filter_complex "\
    color=s=1920x1080:c=black[bg];\
    [0:v]crop=w=1920:h=ih:x=0:y=0[crop1];\
    [0:v]crop=w=iw-1920:h=ih:x=1920:y=0[crop2];\
    [bg][crop1]overlay=x=0:y=0:shortest=1[out1];\
    [out1][crop2]overlay=x=0:y=h[final]" \
    -map [final] out.mov