Created
December 13, 2019 02:11
-
-
Save dericed/ec2439996e3971a836c02502644cb1bf to your computer and use it in GitHub Desktop.
edit process for nttw videos
This file contains hidden or 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
#!/bin/bash | |
SLATE="NTTW4_title.jpg" | |
RECORDING="" | |
INTROTIME=4 | |
INTROTIMEHALF="$(echo "$INTROTIME / 2" | bc)" | |
CREDITSTIME=8 | |
_maketemp(){ | |
mktemp -q "/tmp/$(basename "${0}").XXXXXX" | |
if [ "${?}" -ne 0 ]; then | |
echo "${0}: Can't create temp file, exiting..." | |
_writeerrorlog "_maketemp" "was unable to create the temp file, so the script had to exit." | |
exit 1 | |
fi | |
} | |
while IFS=, read -r season episode filename intime outtime sync speaker title turf notes stage stream remote license | |
do | |
echo "season is $season" | |
echo "episode is $episode" | |
prefix=$(echo "$season $episode" | awk '{printf "S%02iE%02i", $1, $2}') | |
echo "filename is $filename" | |
echo "intime is $intime" | |
echo "outtime is $outtime" | |
echo "sync is $sync" | |
echo "speaker is $speaker" | |
title=$(echo "$title" | sed 's/;/,/g') | |
echo "title is $title" | |
echo "stage is $stage" | |
echo "stream is $stream" | |
stream=$(echo "$stream" | sed 's/;/,/g') | |
echo "remote is $remote" | |
echo "license is $license" | |
leetname=$(echo "$speaker" | sed 's/ /_/g') | |
outputfile="No.Time.To.Wait.${prefix}.${leetname}.1080p.nttw${season}.x264.mp4" | |
echo "$title" > /tmp/title | |
INSEC=$(echo "$intime" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }') | |
INSEC_BACK=$(echo "$INSEC - $INTROTIME" | bc) | |
OUTSEC=$(echo "$outtime" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }') | |
DUR=$(echo "$OUTSEC - $INSEC" | bc) | |
TOCREDITS=$(echo "$DUR - $CREDITSTIME" | bc) | |
echo "in $INSEC out $OUTSEC dur $DUR" | |
echo "toc $TOCREDITS credtime $CREDITSTIME" | |
if [ "$license" = "CC" ] ; then | |
license="This work is licensed under a Creative Commons Attribution 4.0 International License." | |
licensedrawtext=",drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=16:text='${license}':enable='between(t,$TOCREDITS,$DUR)':y=h*0.92:x=(w-text_w)/2" | |
else | |
license="" | |
licensedrawtext="" | |
fi | |
LOUDNESS_DATA=$(ffmpeg -ss "$INSEC_BACK" -i "${filename}" -t "$DUR" -vn -filter_complex "loudnorm=print_format=json" -f null - 2>&1) | |
echo "$LOUDNESS_DATA" | |
measured_I=$(echo "$LOUDNESS_DATA" | grep "input_i" | awk -F\" '{print $4}') | |
measured_LRA=$(echo "$LOUDNESS_DATA" | grep "input_lra" | awk -F\" '{print $4}') | |
measured_TP=$(echo "$LOUDNESS_DATA" | grep "input_tp" | awk -F\" '{print $4}') | |
measured_thresh=$(echo "$LOUDNESS_DATA" | grep "input_thresh" | awk -F\" '{print $4}') | |
target_offset=$(echo "$LOUDNESS_DATA" | grep "target_offset" | awk -F\" '{print $4}') | |
echo "measured_I $measured_I measured_LRA $measured_LRA measured_TP $measured_TP measured_thresh $measured_thresh target_offset $target_offset" | |
echo "HEY ffmpeg -n -nostdin -ss $INSEC_BACK -i $filename -loop 1 -framerate 30 -i $SLATE -t $DUR" | |
ffmpeg -n -nostdin -ss "$INSEC_BACK" -i "$filename" -loop 1 -framerate 30 -i "$SLATE" -t "$DUR" \ | |
-filter_complex "[1:v]split=[logo1][logo2];\ | |
[logo1]scale=1280:720,fade=out:st=$INTROTIME:d=1:alpha=1,drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=48:text=$speaker:enable='between(t,0,$INTROTIME)':y=h*0.75:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=36:textfile=/tmp/title:enable='between(t,0,$INTROTIME)':y=h*0.82:x=(w-text_w)/2[start];\ | |
[logo2]scale=1280:720,fade=in:st=$TOCREDITS:d=1:alpha=1,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=18:text='Stage Coordinator':enable='between(t,$TOCREDITS,$DUR)':y=h*0.58:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=24:text='${stage}':enable='between(t,$TOCREDITS,$DUR)':y=h*0.62:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=18:text='Live Stream Technicians':enable='between(t,$TOCREDITS,$DUR)':y=h*0.68:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=24:text='${stream}':enable='between(t,$TOCREDITS,$DUR)':y=h*0.72:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=18:text='Remote Participant Support':enable='between(t,$TOCREDITS,$DUR)':y=h*0.78:x=(w-text_w)/2,\ | |
drawtext=fontfile=/Library/Fonts/OCRAStd.otf:fontcolor=CDFFCC:fontsize=24:text='${remote}':enable='between(t,$TOCREDITS,$DUR)':y=h*0.82:x=(w-text_w)/2\ | |
${licensedrawtext}[credits];\ | |
[0:v][start]overlay[vid1];[vid1][credits]overlay[vid2];\ | |
[0:a]loudnorm=measured_i=$measured_I:measured_tp=$measured_TP:measured_lra=$measured_LRA:measured_thresh=${measured_thresh},aformat=sample_fmts=s16:channel_layouts=stereo,aresample=48000,afade=t=in:ss=0:d=$INTROTIMEHALF,afade=t=out:st=$TOCREDITS:d=$CREDITSTIME[aud]" \ | |
-map "[vid2]" -map "[aud]" -aspect 16/9 -pix_fmt yuv420p -c:v libx264 -crf 18 -c:a aac -b:a 320k "$outputfile" | |
done < recordings.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment