+get_media_bitrate() {
+ # Use ffprobe to get audio/visual media container bitrate (bits per second integer)
+ # Usage: get_media_bitrate arg1
+ # Input: arg1: str path to file
+ # Output: stdout: int bitrate (bits per second)
+ # Version: 0.0.1
+ # Depends: ffprobe 4.4.2
+ # Ref/Attrib: [1] How to get video duration in seconds? https://superuser.com/a/945604
+ # [2] Determine video bitrate using ffmpeg https://superuser.com/questions/1106343/determine-video-bitrate-using-ffmpeg
+ local file_in
+ file_in="$1";
+ if [[ ! -f $file_in ]]; then
+ die "ERROR:Not a file:$file_in";
+ fi;
+ ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "$file_in";
+
+ #yell "DEBUG:Finished get_media_bitrate with $? on:$1";
+} # Get media container length in seconds via stdout
+transcode_copy() {
+ # Desc: Transcode high bitrate file into smaller opus file
+ # Note: Meant for downsizing large lossless FLAC
+ # Input: arg1 str path to input audio file
+ # arg2 str output file path
+ # var limit_bitrate int max output transcode bitrate (bps)
+ # Output: file
+
+ ffmpeg -nostdin -i "$1" -c:a libopus -b:a "${limit_bitrate}" "${2}.opus";
+}; # transcode to lower bitrate audio file
+