feat(user/bkmml):Add aif and ape extension support
[BK-2020-03.git] / unitproc / bkt-check_parsable_audio_ffprobe
CommitLineData
a9a36cc4
SBS
1#!/usr/bin/env bash
2
3check_parsable_audio_ffprobe() {
4 # Desc: Checks if ffprobe returns valid audio codec name for file
5 # Usage: check_parsable_audio_ffprobe [path FILE]
6 # Version: 0.0.1
7 # Input: arg1: file path
8 # Output: exit code 0 if returns valid codec name; 1 otherwise
9 # Depends: ffprobe, die()
10 local file_in ffprobe_out
11
12 if [[ $# -ne 1 ]]; then die "ERROR:Invalid number of args:$#"; fi;
13
14 file_in="$1";
15
16 # Check if ffprobe detects an audio stream
17 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
18 return_state="true";
19 else
20 return_state="false";
21 fi;
22
23 # Fail if ffprobe returns no result
24 ffprobe_out="$(ffprobe -v error -select_streams a -show_entries stream=codec_name -of default=nokey=1:noprint_wrappers=1 "$file_in")";
25 if [[ -z $ffprobe_out ]]; then
26 return_state="false";
27 fi;
28
29 # Report exit code
30 if [[ $return_state = "true" ]]; then
31 return 0;
32 else
33 return 1;
34 fi;
35} # Checks if file has valid codec name using ffprobe
36
37# Author: Steven Baltakatei Sandoval
38# License: GPLv3+