prompter: I have two videos that each have a different quality setting. How do I create a side-by-side comparison video of them with ffmpeg?

assistant: You can create a side-by-side comparison video using FFmpeg by using the "hstack" filter. Here's an example of how you can use FFmpeg to create a side-by-side comparison video of two videos:

```bash
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=iw/2:ih[left]; [1:v]setpts=PTS-STARTPTS, scale=iw/2:ih[right]; [left][right]hstack" -c:v libx264 -crf 18 -pix_fmt yuv420p output.mp4
```

Here's what each part of the command does:

    -i video1.mp4: This specifies the first input video.
    -i video2.mp4: This specifies the second input video.
    -filter_complex: This specifies the filter graph to apply to the input videos.
    "[0:v]setpts=PTS-STARTPTS, scale=iw/2:ih[left]": This takes the first input video and sets the presentation timestamps, scales the video to half its width, and labels the result as "left".
    "[1:v]setpts=PTS-STARTPTS, scale=iw/2:ih[right]": This takes the second input video and sets the presentation timestamps, scales the video to half its width, and labels the result as "right".
    [left][right]hstack: This creates a side-by-side comparison video by stacking the "left" and "right" videos horizontally.
    -c:v libx264 -crf 18: This sets the video codec to H.264 and the CRF value to 18, which provides a balance between quality and file size.
    -pix_fmt yuv420p: This sets the pixel format to YUV420P, which is a widely supported format for H.264 encoding.
    output.mp4: This specifies the output file name.

Note that this is just one example of how you can use FFmpeg to create a side-by-side comparison video. You can adjust the parameters as needed to achieve the desired output.

prompter: Can I do this without reencoding the video

assistant: Using FFmpeg, you can
 create a side-by-side comparison video with the following command:

```bash
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]" -map "[v]" output.mp4
```

prompter: Will this work on windows?

assistant: Yes, FFmpeg can work on Windows, you can download the compiled Windows version of FFmpeg from their official website: https://ffmpeg.org/download.html. Once you have installed FFmpeg on your Windows machine, you can use the command mentioned in your previous question in a command prompt or terminal window to create a side-by-side comparison video.

assistant: Yes, this will work on windows, but you need to first install ffmpeg.
To do this, access the download page here: https://ffmpeg.org/download.html
and download ffmpeg to your computer.

assistant: Yes, FFmpeg can work on Windows. FFmpeg is a cross-platform software project that is available for Windows, Linux, and macOS. On Windows, it can be installed using various methods such as compiling from source code or using pre-compiled binaries. There are also third-party distributions that package FFmpeg for Windows, such as Zeranoe FFmpeg, which make it easier to install and use.

assistant: You can use ffmpeg's concat filter to join the two videos into a single file:
// Create files list
echo file file1.mp4 >  mylist.txt 
echo file file2.mp4 >> mylist.txt
// Concatenate files
ffmpeg -f concat -i mylist.txt -c copy output.mp4

prompter: How can I change the aspect ratio such that file2 has the same aspect ratio as file1?

assistant: To change the aspect ratio of file2 to match file1, you can add a scale filter to the ffmpeg command like this:

// Create files list
echo file file1.mp4 > mylist.txt
echo file file2.mp4 >> mylist.txt
// Concatenate files
ffmpeg -f concat -i mylist.txt -vf "scale=iw*sar:ih,setsar=1" -c:v libx264 -crf 19 -preset slow -c:a copy output.mp4

This will scale the aspect ratio of file2 to match file1, and use the x264 codec with a constant rate factor of 19 and the "slow" preset for encoding the video. The audio stream is copied without re-encoding using the "copy" option.

prompter: Thanks! That worked. Will this also work for MKV files?

assistant: Thanks, nice code snipplet