Skip to content

Instantly share code, notes, and snippets.

@kevinwright
Last active February 18, 2024 21:14
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kevinwright/24baf2470d4fbd1d12b5cd1118e7d680 to your computer and use it in GitHub Desktop.
Save kevinwright/24baf2470d4fbd1d12b5cd1118e7d680 to your computer and use it in GitHub Desktop.
Use ffmpeg to build prores proxies for Premiere Pro
#!/usr/bin/env bash
# Usage notes
# ===========
#
# proxy_watermark.png needs to be in the same directory as the script
# download from here: http://whoismatt.com/images/2016/7-july/adobe_proxy_logo.png
#
# on OSX, both pv and ffmpeg will need to be installed via homebrew
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
inputfile=$1
nakedname="${inputfile%.*}"
ext="${inputfile##*.}"
outputfile="Proxies/${nakedname}-proxy.${ext}"
echo "outputfile = $outputfile"
mkdir -p 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)
eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width $inputfile)
inputres=${streams_stream_0_width}:${streams_stream_0_height}
#TODO: make this 1024:540 if source is C4K
outputres="1280:720"
echo "inputres = $inputres"
echo "outputres = $outputres"
# EXPLANATION
# ===========
#
# pv = pipeview, shows progress and estimated time
#
# -v warning turn down verbosity to only warnings
#
# -profile:v N
# where N = 0 -> proxy 1 -> lt 2 -> std 3 -> hq
#
# -i logo.png = a SECOND input file, with an overlay image
# -filter_complex "overlay=W-w-5:H-h-5/2" = make an overlay, position 5px from bottom-right
#
pv $inputfile | ffmpeg \
-loglevel warning \
-i pipe:0 \
-i "$scriptdir/proxy_watermark.png" \
-filter_complex "[0:v]scale=$outputres, overlay=W-w-5:H-h-5/2" \
-codec:a copy \
-codec:v prores \
-profile:v 0 \
"$outputfile"
@kevinwright
Copy link
Author

kevinwright commented Dec 5, 2022

Hi @anjszulc
If you copy/pasted the file then you probably haven't flagged it as being executable.

You can do that with

chmod +x /Volumes/6TB\ HDD\ Venom/ResilioSync/prores/proresproxy.sh

I've also updated the gist to quote filenames in a couple of places where it would have got confused by spaces in the script path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment