style(user/bknpass):Simplify boilerplate
[BK-2020-03.git] / unitproc / bkt-get_media_length
1 #!/usr/bin/env bash
2
3 get_media_length() {
4 # Use ffprobe to get media container length in seconds (float)
5 # Usage: get_media_length arg1
6 # Input: arg1: path to file
7 # Output: stdout: seconds (float)
8 # Depends: ffprobe 4.1.8
9 # Ref/Attrib: [1] How to get video duration in seconds? https://superuser.com/a/945604
10 local file_in
11 file_in="$1";
12 if [[ ! -f $file_in ]]; then
13 die "ERROR:Not a file:$file_in";
14 fi;
15 ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file_in";
16 } # Get media container length in seconds via stdout
17
18 # Author: Steven Baltakatei Sandoval
19 # License: GPLv3+