AI Resource Pro / full-access-films · airesourcepro.com / 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. |
| 3 | set -e |
| 4 | cd "$(dirname "$0")/../film-$1" |
| 5 | out=../video/renders |
| 6 | if [ "$2" = 1080 ]; then |
| 7 | npx hyperframes render --quality delivery --video-frame-format png -o "$out/.$1-1080.mp4" |
| 8 | 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" |
| 9 | rm "$out/.$1-1080.mp4" |
| 10 | secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out/$1-full-access-1080p.mp4") |
| 11 | kbps=$(python3 -c "print(int(19.5*8192/$secs-64))") |
| 12 | 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 |
| 13 | 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" |
| 14 | echo STAGE 1080 done |
| 15 | else |
| 16 | npx hyperframes render --resolution 4k --fps 60 --quality delivery --video-frame-format png -o "$out/.$1-4k.mp4" |
| 17 | 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" |
| 18 | rm "$out/.$1-4k.mp4" |
| 19 | echo STAGE 4k done |
| 20 | fi |