ffmpegvideo-editing

Commands to cut videos in half horizontally or vertically, and rejoin them later


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?


Solution

  • 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?