Split screen

Problem

Compare two video files by using a vertical split screen.

Solution

ffmpeg \
    -i input_file_1 \
    -i input_file_2 \
    -filter_complex \
        "[0]crop=iw/2:ih:0:0, \
            pad=iw*2:ih[left]; \
        [1]crop=iw/2:ih:iw/2:0[right]; \
        [left][right]overlay=w" \
    output_file

Command syntax

ffmpeg
starts the command
-i input_file_1
path, name and extension of the first input files
-i input_file_2
path, name and extension of the second input files
-filter_complex
see the discussion below
output_file
path, name and extension of the output file

Discussion

A complex filter is needed:

  • the first input file is cropped vertically and the left half is padded into the original size;
  • the second input file is cropped vertically to the right half;
  • the overlay filter completes horizontally the two half images to a full image.

Exercises

  • horizontal split screen
  • split screen with a tiny black line between the two sectors
  • diagonal split screen

2018–04–08