Advertisement
Guest User

50 frames refined

a guest
Jun 28th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. duration=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $1)
  4.     echo "duration: $duration"
  5.  
  6. fps=$( ffprobe -v 0 -of compact=p=0 -select_streams 0 -show_entries stream=r_frame_rate $1 | sed 's/r_frame_rate=//' | bc )
  7.     echo "fps: $fps"
  8.  
  9. TotalFrames=$( bc <<< "$duration*$fps" )
  10.     echo "Total Frames: $TotalFrames"
  11.  
  12. clipsCount=100
  13.  
  14. clipsLength=50
  15.  
  16. for i in $( seq 0 $( bc <<< "$clipsCount-1" ) ); do \
  17.     skipFrames=$( bc <<< "$i*($TotalFrames/$clipsCount)" )
  18.     skipTime=$( bc <<< "$skipFrames/$fps" )
  19.     ffmpeg -ss $skipTime -i $1 -vframes $clipsLength \
  20.         -c:v h264 -crf 30 -preset ultrafast -pix_fmt yuv420p \
  21.         -c:a libopus -b:a 128k -vbr on \
  22.         -y $i-50frames.mkv
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement