X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/849106f7246e47bc077d7f3b8228cec717a8e63d..26f0533782d8c57fb95b8df4f55057edcbf17703:/unitproc/bkt-get_media_length diff --git a/unitproc/bkt-get_media_length b/unitproc/bkt-get_media_length new file mode 100644 index 0000000..76c8f3d --- /dev/null +++ b/unitproc/bkt-get_media_length @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +get_media_length() { + # Use ffprobe to get media container length in seconds (float) + # Usage: get_media_length arg1 + # Input: arg1: path to file + # Output: stdout: seconds (float) + # Depends: ffprobe 4.1.8 + # Ref/Attrib: [1] How to get video duration in seconds? https://superuser.com/a/945604 + local file_in + file_in="$1"; + if [[ ! -f $file_in ]]; then + die "ERROR:Not a file:$file_in"; + fi; + ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file_in"; +} # Get media container length in seconds via stdout + +# Author: Steven Baltakatei Sandoval +# License: GPLv3+ \ No newline at end of file