Branchwell

Become a Pro / full-access-films · becomeapro.ai / tools / deliver.sh

1#!/bin/bash
2# deliver.sh <name> <1080|4k>: renders film-<name>, puts the checked mix back on, and makes a phone copy at 1080.
3set -e
4cd "$(dirname "$0")/../film-$1"
5out=../video/renders
6if [ "$2" = 1080 ]; then
7npx hyperframes render --quality delivery --video-frame-format png -o "$out/.$1-1080.mp4"
8ffmpeg -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"
9rm "$out/.$1-1080.mp4"
10secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out/$1-full-access-1080p.mp4")
11kbps=$(python3 -c "print(int(19.5*8192/$secs-64))")
12ffmpeg -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
13ffmpeg -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"
14echo STAGE 1080 done
15else
16npx hyperframes render --resolution 4k --fps 60 --quality delivery --video-frame-format png -o "$out/.$1-4k.mp4"
17ffmpeg -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"
18rm "$out/.$1-4k.mp4"
19echo STAGE 4k done
20fi