Friday 12 July 2013

BASH scripting ffprobe duration

Somewhat overjoyed today.

I don't get to program much at work anymore, well SQL scripts mainly on Oracle, but I got the chance just to write a really simple bash script that output to a CSV file today on Linux (RHEL 6 if you care).  Bash doesn't really pass as programming but it can be a really nice shortcut.

This was to just get the duration times of audio files, which don't have the same name as the IDs I was given so you have to use find and then move stuff to vars and pipe them quite a bit through (what you would think would be sed and awk) but just turned out to be through cut.

I can't print the whole script but something similar helped me online to get just the duration of an audio track - this is to clip off the hours - this will give you MM:SS.mmmm


DURATION=$(ffprobe  "$INPUT_FILE" 2>&1 | grep Duration: |  \
        cut -f3,4 -d: | cut -f1 -d,);