Last active
August 25, 2019 08:12
-
-
Save paullaffitte/7b7570cff02f762fa54df80bb1d8fe61 to your computer and use it in GitHub Desktop.
An MLT proxifier for shotcut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
INPUT="$1" | |
if [[ -z "$INPUT" ]]; then | |
echo 'Usage: proxify [filename.mlt]' | |
echo '(The current folder sould include a "raw" folder containing your raw footages in mp4 format)' | |
echo 'xpath is required for this tool to work' | |
exit | |
fi | |
mkdir -p proxy | |
mkdir -p backups | |
filename=$(basename -- "$INPUT") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
timestamp=$(date +%s) | |
cp -v "$INPUT" "backups/${filename}_${timestamp}.${extension}" | |
sed -i '' -re 's/proxy/raw/g' "$INPUT" | |
xpath -q -e '//property[@name="resource"]/text()' "$INPUT" > /tmp/files_to_proxify | |
while read -r i; do | |
if echo "$i" | grep -vq "^raw/"; then | |
echo "input isn't a raw file, skipping (filename: $i)" | |
continue | |
fi | |
if [[ -f "$i" ]]; then | |
filename=$(basename -- "$i") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
dest="proxy/${filename}.${extension}" | |
echo "$i -> $dest" | |
ffmpeg -i "$i" -n -nostdin -strict -2 -vf scale=iw/6:ih/6 "$dest" | |
else | |
echo "Warning: file not found (filename: $i)" | |
fi | |
done < /tmp/files_to_proxify | |
sed -i '' -re 's/raw/proxy/g' "$INPUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment