-#!/bin/bash
-# Desc: Converts file readable by ffmpeg to FLAC audio format
+#!/usr/bin/env bash
+# Desc: Converts file readable by ffmpeg to FLAC audio file
# Usage: convert_file_to_flac.sh [path]
-# Version: 0.0.1
+# Version: 0.0.4
# Ref/Attrib: [1] Convert audio file to FLAC with ffmpeg? https://superuser.com/a/802126
+# [2] How to specify flac compression level when converting with avconv? https://askubuntu.com/questions/544651/
+# [3] How can I extract audio from video with ffmpeg? https://stackoverflow.com/a/27413824
+# Depends: ffmpeg version 4.4.2, ffprobe version 4.4.2, bash version 5.1.16
declare -Ag appRollCall # Associative array for storing app status
declare -Ag fileRollCall # Associative array for storing file status
if ! check_parsable_audio_ffprobe "$1"; then
die "FATAL:Not an audio file:$1"; fi;
- # Convert file to FLAC
- try ffmpeg -i "$1" -f "$1".flac
+ # Convert file to FLAC. See [1], [2]
+ try ffmpeg -i "$1" -vn -c:a flac -map_metadata 0 -compression_level 12 "$1".flac
}; # main program
main "$@";