Skip to content

Instantly share code, notes, and snippets.

@hh-lohmann
Created December 5, 2021 20:12
Show Gist options
  • Save hh-lohmann/1d9d58956a86907026afd952cf47d39e to your computer and use it in GitHub Desktop.
Save hh-lohmann/1d9d58956a86907026afd952cf47d39e to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Get basic info about audio / video file (MP4, MP3, WAV, WEBM, ...) by ffprobe
# - Usually you should have ffmpeg on your system, including ffprobe
# - ffprobe gives you MUCH MUCH (MUCH) information
# - this little helper script reduces ffprobe's info hell to typical core information
# - use this script as a template for personal information interests
# - don't get mislead by "-v error" - it means "don't get verbose WITHOUT errors"
# - information is given as JSON for readability & easy automated consumptione
qrffprobe(){
showHelp(){
marginLeft=" "
scdesc="Basic info about audio / video files using ffprobe"
printf "\n\n$marginLeft%s\n$marginLeft%s\n$marginLeft%s\n\n\n" "$0" "$scdesc" "Syntax: $0 AV-FILE"
unset marginLeft scdesc
}
[ "$1" = "" ] && showHelp && return 1
[ "$1" = "--help" ] && showHelp && return 1
[ ! -e "$1" ] && echo "Input file '$1' not found" && return 1
! which ffprobe >/dev/null 2>&1 && echo "ERROR: ffprobe not available" && return 1
ffprobe -v error -show_entries stream=index,codec_type,codec_name,width,height,bit_rate,display_aspect_ratio,duration -of json "$1"
unset showHelp
}
qrffprobe "$@"
# ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment