unix4artists/ffmpeg/basic/prores.sh

55 lines
1.6 KiB
Bash

#!/bin/bash -e
#####################################################
#
# This command will re-encode a video into an MOV
# container with a ProRes HQ (422) video stream and
# audio preserved in its original format.
#
# -i "${INPUT}"
# Sets the first argument, saved as variable "$INPUT"
# as the input file that ffmpeg will re-encode. Must
# go at the beginning of your command.
#
# -c:v prores_ks
# Sets the video codec of the output video to be ProRes
# using the "prores_kostya" library.
#
# -profile:v 3
# Sets the ProRes profile to 3 or "HQ" use on the output
# video stream. The profiles available: 0 = proxy (PR),
# 1 = light (LT), 2 = standard (ST), 3 = high quality (HQ),
# 4 = 4444, 5 = 4444 (XQ)
#
# -c:a copy
# Copies the audio stream and preserves the format
# and codec from the original file.
#
# "${OUTPUT}"
# The output video file, which should be the last
# argument you provide.
#
# More info: https://avpres.net/FFmpeg/im_ProRes.html
# https://codecs.multimedia.cx/2012/03/a-few-words-about-my-prores-encoder/
#
# Usage: bash ffmpeg/basic/prores.sh <input video> <output video>
#
#####################################################
INPUT="${1}"
OUTPUT="${2}"
# Check if input and output arguments are supplied
if [ "${INPUT}" == "" ] || [ "${OUTPUT}" == "" ]; then
echo "Please provide input and output files as your first and second arguments"
exit 1
fi
# Check if output file extension is .mov
if [[ "${OUTPUT}" != *".mov" ]]; then
echo "Please use an .mov extension on your output file argument"
exit 2
fi
# Command to re-encode the input video into ProRes
ffmpeg -i "${INPUT}" -c:v prores_ks -profile:v 3 -c:a copy "${OUTPUT}"