I want to crop the video at some position and move the part next to the part that wasn't cropped. (See image, it explains better)

enter image description here


This should do it:

ffmpeg -i input.mp4 \
-filter_complex "[0:v] crop=iw/3:ih:0:0,pad=iw:2*ih [left]; \
 [0:v] crop=iw/3:ih:(iw/3)+1:0 [middle]; \
 [0:v] crop=iw/3:ih:(2*iw/3)+1:0 [right]; \
 [left][middle] overlay=0:main_h/2,pad=iw:(3*ih/2) [out1]; \
 [out1][right] overlay=0:(2*main_h/3) [fout] " \
  -c:v libx264 -an -map "[fout]" trisected-vertical-overlay.mp4

I haven't supplied any specific video or audio encoding parameters. This just shows the overlay filter to use. You'll have to encode and map the audio, as needed.


Using crop and vstack:

ffmpeg -i input -filter_complex \
"[0:v]crop=iw/3:ih:0:0[left]; \
 [0:v]crop=iw/3[center]; \
 [0:v]crop=iw/3:ih:ow*2:0[right]; \
 [left][center][right]vstack=inputs=3[v]" \
-map "[v]" -map 0:a -c:a copy output 
  • vstack is faster than pad + overlay.

  • If your ffmpeg is too old for the vstack filter then just download a recent build.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.