Convert video to 30FPS CFR

The following can be used to convert all video files in a directory to 29.97 (30000/1001) FPS, and constant frame rate (CFR).
This is useful for preparing dashcam video for editing, where they usually start as variable frame rate (VFR), which is no good for editing.

The steps are:

  • List the files in the directory and use that as the file list to join
  • Put the word “file” at the start of each line, which is what ffmpeg uses
  • Run the command to join (concatenate) the video files
#!/bin/bash

ls *.mp4 > filestoconvert

while read -r line; do

currentfile="$line";

ffmpeg -nostdin -loglevel verbose \
-i $currentfile \
-map 0 \
-map_metadata 0 \
-map -0:d \
-map -0:s \
-map -0:t \
-ignore_unknown \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 20 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-y \
-r 30000/1001 \
cfr_$currentfile

done < filestoconvert

Now you will have extra files with the cfr_ prefix in the directory.