Skip to content

Instantly share code, notes, and snippets.

@plaffitt
Last active August 15, 2019 11:45
Show Gist options
  • Save plaffitt/13fd44c9a0b7266e33cad6c3f1a3d64c to your computer and use it in GitHub Desktop.
Save plaffitt/13fd44c9a0b7266e33cad6c3f1a3d64c to your computer and use it in GitHub Desktop.
Convert movies to constant framerate with FFmpeg reading filenames on stdin
#! /usr/bin/env bash
dest=$1
fps=$2
if [[ -z "$dest" ]]; then
dest='.'
fi
if [[ -z "$fps" ]]; then
fps=60
fi
IFS=$' \n' read -d '' -r -a filenames
for i in "${filenames[@]}"; do
filename=$(basename -- "$i")
extension="${filename##*.}"
filename="${filename%.*}"
echo "$i -> ${dest}/${filename}_${fps}_const.${extension}"
ffmpeg -i "$i" -filter:v fps=fps=$fps -strict -2 "${dest}/${filename}_${fps}_const.${extension}";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment