Skip to content

Instantly share code, notes, and snippets.

@saulirajala
Forked from kevinwright/proresproxy.sh
Last active February 14, 2022 19:58
Show Gist options
  • Save saulirajala/46e9b7fb8e0ffe8dd2574507f3c5b873 to your computer and use it in GitHub Desktop.
Save saulirajala/46e9b7fb8e0ffe8dd2574507f3c5b873 to your computer and use it in GitHub Desktop.
Use ffmpeg to build proxies for Davinci Resolve from iphone video clips
#!/usr/bin/env bash
# Usage notes
# ===========
#
# ./proresproxy.sh my-project
#
# This will create Proxies -folder inside of my-project where it will put all video files inside of my-project
#
# .
# proresproxy.sh
# my-project
#
# =>
#
# .
# proresproxy.sh
# my-project
# Proxies
#
# on OSX, both pv and ffmpeg will need to be installed via homebrew
inputFolder=$1
rm -rf "$inputFolder/Proxies"
mkdir "$inputFolder/Proxies"
# find input resolution
# =====================
# input aspects:
# cine 4K = 4096:2160 (1.9:1 = 1.896) - proxy at 1024:540
# UHD(4K) = 3840:2160 (16:9 = 1.777) - proxy at 720p
# 1080p = 1920:1080 (16:9 = 1.777) - proxy at 720p
# 720p = 1280:720 (16:9 = 1.777)
#
# proxy aspects:
# 1024x540 = 1.9:1
# 1280x720 = 16:9
# 1536x790 = ??? (1.944)
outputres="768:432"
# EXPLANATION
# ===========
#
# pv = pipeview, shows progress and estimated time
#
# -v warning turn down verbosity to only warnings
#
# -noautorotate do not autorotate videos according to metadata. Helps to keep the video clips upside up in resolve
#
# -profile:v N
# where N = 0 -> proxy 1 -> lt 2 -> std 3 -> hq
#
#
fileCount=$(ls -lR "$inputFolder"/*.mov | wc -l)
# Get rid of whitespaces
fileCount=$(echo "$fileCount" | xargs)
i=1
cd "$inputFolder"
for inputfile in *.mov;
do
filename="${inputfile%.*}"
ext="${inputfile##*.}"
outputfile="Proxies/${filename}.${ext}"
echo "Generating $i/$fileCount: $inputfile"
ffmpeg \
-loglevel warning \
-noautorotate \
-i "$inputfile" \
-filter_complex "scale=$outputres" \
-codec:a copy \
-codec:v prores \
-profile:v 0 \
$outputfile
((i=i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment