+#!/usr/bin/env bash
+
+check_parsable_audio_ffprobe() {
+ # Desc: Checks if ffprobe returns valid audio codec name for file
+ # Usage: check_parsable_audio_ffprobe [path FILE]
+ # Version: 0.0.1
+ # Input: arg1: file path
+ # Output: exit code 0 if returns valid codec name; 1 otherwise
+ # Depends: ffprobe, die()
+ local file_in ffprobe_out
+
+ if [[ $# -ne 1 ]]; then die "ERROR:Invalid number of args:$#"; fi;
+
+ file_in="$1";
+
+ # Check if ffprobe detects an audio stream
+ if ffprobe -v error -select_streams a -show_entries stream=codec_name -of default=nokey=1:noprint_wrappers=1 "$file_in" 1>/dev/null 2>&1; then
+ return_state="true";
+ else
+ return_state="false";
+ fi;
+
+ # Fail if ffprobe returns no result
+ ffprobe_out="$(ffprobe -v error -select_streams a -show_entries stream=codec_name -of default=nokey=1:noprint_wrappers=1 "$file_in")";
+ if [[ -z $ffprobe_out ]]; then
+ return_state="false";
+ fi;
+
+ # Report exit code
+ if [[ $return_state = "true" ]]; then
+ return 0;
+ else
+ return 1;
+ fi;
+} # Checks if file has valid codec name using ffprobe
+
+# Author: Steven Baltakatei Sandoval
+# License: GPLv3+