#!/usr/bin/env bash # shellcheck disable=SC1004 # shellcheck disable=SC2016 # shellcheck disable=SC2126 set -eux test $# -gt 0 || set -- "${0%/*}"/{old,new}/audio #preserveCoverArt="-vcodec copy -f mkv" find "$@" -depth -type f \( -name "*.mp3" -o -name "*.m4a" -o -name "*.audio*" -o -name "*.unknown_video" \) -print0 | sort -n -z | xargs -0 -P "$(lscpu --online -p | grep -v "#" | wc -l)" -I {} bash -c ' nice -n 19 ffmpeg -y -i "$0" \ -map_metadata 0:s:a:0 \ -c:a libopus -b:a 32k \ -application voip "${0%.*}.opus" && rm -vf "$0" ' {} \; # -map_metadata 0:s:a:0 # copies metadata from the first input file (0:), # first audio stream (s:a:0) to all output files.