dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

opus-soundtrack.sh (1048B)


      1 #!/usr/bin/env bash
      2 
      3 set -e
      4 
      5 BITRATE_KBPS="100"
      6 
      7 oldIFS="$IFS"
      8 IFS=$'\n'
      9 dirs=( $(find m4asoundtracks/ -type d -links 2 | sort) )
     10 soundtracks=( $(find m4asoundtracks/ -type f | grep -v 'output.jpg$' | sort) )
     11 IFS="$oldIFS"
     12 
     13 [ -d opus/ ] && rm -rf opus
     14 mkdir opus
     15 
     16 for dir in "${dirs[@]}"; do
     17 	echo "Dir: ${dir}"
     18 	firstFile="$(find "$dir" -type f | grep 'm4a$' |  head -n 1)"
     19 	outputDir="$(echo "$dir" | sed 's/^m4asoundtracks/opus/g')"
     20 	mkdir -p "$outputDir"
     21 	echo "First File: ${firstFile}"
     22 	ffmpeg -y -i "$firstFile" -map 0:1 "$dir/output.jpg"
     23 	cp "${dir}/output.jpg" "${outputDir}/output.jpg"
     24 	# [[ "$dir" == *"Other"* ]] && exit
     25 done
     26 
     27 i=0
     28 for file in "${soundtracks[@]}"; do
     29 	echo File: "$file"
     30 	outputFile="$(echo "$file" | sed 's/^m4asoundtracks/opus/g' | sed 's/m4a$/opus/g')"
     31 	outputDir="$(dirname "$outputFile")"
     32 	mkdir -p "$outputDir"
     33 	echo ffmpeg -i "$file" -b:a "${BITRATE_KBPS}000" "$outputFile"
     34 	ffmpeg -i "$file" -b:a "${BITRATE_KBPS}000" "$outputFile"
     35 	opustags --set-cover "$outputDir/output.jpg" "$outputFile" -i
     36 	i=$((i+1))
     37 done