Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- source_dir='.'
- file_ptrn='*.webm'
- dest_dir='truncated'
- for file in $(find -L $source_dir -name $file_ptrn); do
- s=$(avconv -i $file 2>&1 | grep -o -E '|Duration: [^.]+|')
- sec=${s##*:}
- s=${s%:*}
- min=${s##*:}
- duration=$(( ${sec#0} + ${min#0} * 60 ))
- max_start=$(( $duration - 300 ))
- start=0
- while (( $start < $max_start )); do
- dest=$dest_dir/$(</dev/urandom tr -dc A-Za-z0-9 | head -c 6).webm
- start=$(( $start + $max_start / 5 ))
- trunc_m=$( (( $start > 60 )) && printf %02d "$(( $start / 60 ))" || echo '00' )
- trunc_s=$( printf %02d $(( $start - $trunc_m * 60 )) )
- avconv -i $file -ss 00:$trunc_m:$trunc_s -t 00:05:00 -codec copy $dest
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement