Created
September 22, 2014 12:37
-
-
Save tfogo/1ecf353492dd652db98d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| FILES=/home/tim/marathon/output/*.mp4 | |
| printf "{\n\t" >> /home/tim/p/video-annotator/offsets.json | |
| for f in $FILES | |
| do | |
| time="$(ffprobe "$f" 2>&1 >/dev/null | grep -Po '(?<=Duration:\s)\d{2}:\d{2}:\d{2}')" | |
| hrs="$(echo "$time" | grep -Po '\d{2}(?=:\d{2}:\d{2})')" | |
| mins="$(echo "$time" | grep -Po '(?<=\d{2}:)\d{2}(?=:\d{2})')" | |
| secs="$(echo "$time" | grep -Po '(?<=\d{2}:\d{2}:)\d{2}')" | |
| filename="$(echo "$f" | grep -Po '(?<=/home/tim/marathon/output/).*(?=\.mp4)')" | |
| echo "filename $filename | hrs $hrs | mins $mins | secs $secs | time $time" | |
| let sectime=10#$hrs*3600+10#$mins*60+10#$secs | |
| filenamebase="$(echo "$f" | grep -Po '.*(?=_*)')" | |
| filenameuscore="$(echo "$f" | grep -Po '(?<=_).*(?=\.mp4)')" | |
| wasin=0 | |
| # if [[ $sectime -le 150 ]] | |
| # then | |
| # printf "$filename \n" >> /home/tim/p/video-annotator/nonsplitfiles | |
| # fi | |
| while read line | |
| do | |
| if [[ line == filenamebase ]] | |
| then | |
| offset=0 | |
| wasin=1 | |
| fi | |
| done < "/home/tim/p/video-annotator/nonsplitfiles" | |
| if [[ wasin -eq 0 ]] | |
| then | |
| offset=120*$filenameuscore | |
| fi | |
| printf "$filename: {\n\t\ttime: $sectime,\n\t\toffset: $offset\n\t}\n\t" >> /home/tim/p/video-annotator/offsets.json | |
| done | |
| printf "}" >> /home/tim/p/video-annotator/offsets.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment