# Video Preparation Commands

This file contains `ffmpeg` commands for preparing video files for PSNR analysis, such as trimming and burning in frame numbers.

```bash
in1="output_trimmed-frames.mp4" # Source video with burned-in frames
in2="output_trimmed-frames-crf20.mp4" # CRF 20 compressed video with burned-in frames
in3="output_trimmed-frames-crf22.mp4" # CRF 22 compressed video with burned-in frames
```

## Source Trim Video

Use this command to trim the original source video (`IMG_3885.MOV`) to 5 seconds and output the result as a high-quality MP4 file.

```bash
ffmpeg -y \
  -ss 00:00:00 -i IMG_3885.MOV \
  -t 00:00:05 \
  -c:v libx264 -preset veryslow -crf 18 \
  -c:a copy \
  output_trimmed.mp4
```

# Source Burn frame number on video

Use this command to burn frame numbers onto the trimmed source video (`output_trimmed.mp4`) and output the result to the file specified by `in1`.

```bash
ffmpeg -y \
  -i output_trimmed.mp4 \
  -vf "drawtext=fontfile=/Library/Fonts/Arial.ttf:\
text='Frame %{frame_num}':\
x=10:y=10:\
fontsize=24:\
fontcolor=white@1.0:\
box=1:boxcolor=black@0.5" \
  -c:v libx264 -preset veryslow -crf 18 \
  -c:a copy \
  "$in1"
```

## Install fontconfig (if you haven’t) via Homebrew:

```bash
brew install fontconfig
```

Tell ffmpeg/fontconfig where the config directory is. In Bash (or zsh) do:

```bash
export FONTCONFIG_PATH="$(brew --prefix)/etc/fonts"
```

# Different video encoding compression for testing

Use these commands to create compressed versions of the source video with burned-in frames (`$in1`) with different CRF values.

## CRF 22

```bash
ffmpeg -i "$in1" -c:v libx264 -crf 22 -preset slow -c:a copy "$in3"
```

## CRF 20

```bash
ffmpeg -i "$in1" -c:v libx264 -crf 20 -preset slow -c:a copy "$in2"
```
