X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/b8f798aa115328694754d1c343127440c270a83f..a9a36cc48e1b18d63c1b1f240c9347191ec8d67f:/unitproc/bktemp-check_parsable_audio_ffprobe diff --git a/unitproc/bktemp-check_parsable_audio_ffprobe b/unitproc/bktemp-check_parsable_audio_ffprobe new file mode 100644 index 0000000..9230a3f --- /dev/null +++ b/unitproc/bktemp-check_parsable_audio_ffprobe @@ -0,0 +1,38 @@ +#!/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+