Skip to content

Instantly share code, notes, and snippets.

@eralpkaraduman
Created December 5, 2013 11:28
Show Gist options
  • Save eralpkaraduman/7803836 to your computer and use it in GitHub Desktop.
Save eralpkaraduman/7803836 to your computer and use it in GitHub Desktop.
logs duration of videos between filename range to file as file,duration (number of seconds)
#!/bin/bash
START=4699
END=4824
VIDEO_PATH="/media/videoStorage/wowzaVideoFiles/cevaptv/"
EXT="_240p.mp4"
rm seconds.log
for((i=$START; i<=$END; i++))
do
file=$VIDEO_PATH$i$EXT
#echo $file
ff=$(ffmpeg -i $file 2>&1)
d="${ff#*Duration: }"
du="${d%%,*}"
time=(`echo $du | tr ":" "\n"`)
#echo ${time[@]}
h=${time[0]}
h=`echo $h|sed 's/^0*//'`
m=${time[1]}
m=`echo $m|sed 's/^0*//'`
s=${time[2]}
s=`echo $s|sed 's/^0*//'`
ss=(`echo $s | tr "." "\n"`)
s=${ss[0]}
#echo ${(time[0]*3600)+(time[1]*60)+(time[2])}
echo $i,$((s+m*60+h*3600)) >> seconds.log
done
echo ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment