#!/bin/bash # deliver.sh <1080|4k>: renders film-, puts the checked mix back on, and makes a phone copy at 1080. set -e cd "$(dirname "$0")/../film-$1" out=../video/renders if [ "$2" = 1080 ]; then npx hyperframes render --quality delivery --video-frame-format png -o "$out/.$1-1080.mp4" ffmpeg -y -v error -i "$out/.$1-1080.mp4" -i assets/mix.m4a -map 0:v -map 1:a -c copy -movflags +faststart "$out/$1-full-access-1080p.mp4" rm "$out/.$1-1080.mp4" secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out/$1-full-access-1080p.mp4") kbps=$(python3 -c "print(int(19.5*8192/$secs-64))") ffmpeg -y -v error -i "$out/$1-full-access-1080p.mp4" -vf scale=-2:540 -c:v libx264 -b:v ${kbps}k -pass 1 -passlogfile "/tmp/$1pass" -an -f null /dev/null ffmpeg -y -v error -i "$out/$1-full-access-1080p.mp4" -vf scale=-2:540 -c:v libx264 -b:v ${kbps}k -pass 2 -passlogfile "/tmp/$1pass" -c:a aac -b:a 64k -movflags +faststart "$out/$1-full-access-phone.mp4" echo STAGE 1080 done else npx hyperframes render --resolution 4k --fps 60 --quality delivery --video-frame-format png -o "$out/.$1-4k.mp4" ffmpeg -y -v error -i "$out/.$1-4k.mp4" -i assets/mix.m4a -map 0:v -map 1:a -c copy -movflags +faststart "$out/$1-full-access-4k60.mp4" rm "$out/.$1-4k.mp4" echo STAGE 4k done fi