Advertisement
Guest User

Untitled

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