9

How can I use ffmpeg to cut video in half, vertically or horizontally by resolution; so for a 640 x 480 video, I want to separate that into two halves with a resolution of 320 x 480, or to separate it into two halves horizontally with a resolution of 640 x 240; and afterward, I need to be able to join the separated videos again to make a single video with the original resolution. How can this be done?

White Grimace
  • 93
  • 1
  • 3

1 Answers1

8

separate into two halves

Use the crop filter:

vertical (top/bottom)

ffmpeg -i input -filter_complex "[0]crop=iw:ih/2:0:0[top];[0]crop=iw:ih/2:0:oh[bottom]" -map "[top]" top.mp4 -map "[bottom]" bottom.mp4

horizontal (left/right)

ffmpeg -i input -filter_complex "[0]crop=iw/2:ih:0:0[left];[0]crop=iw/2:ih:ow:0[right]" -map "[left]" left.mp4 -map "[right]" right.mp4

join the separated videos

Use the vstack/hstack filters as shown in Vertically or horizontally stack several videos using ffmpeg?

jox
  • 2,218
  • 22
  • 32
llogan
  • 121,796
  • 28
  • 232
  • 243
  • For the horizontal portion, Shouldn't the "right" portion be ow+1 instead of ow? If using ow, then you start (for instance) a 1440x1080p video at 0 for 720px for left side and 720 for 720px for right, when that would only take you to 1439th pixel, or am I wrong? (ie: you're duplicating the 720th vertical row of pixels when you put them back together) – Jann May 17 '23 at 17:49
  • This is fantastic and works for VR360! Thank you! – Michael N Aug 27 '23 at 18:09