Advertisement
metalx1000

FFMPEG Extract 100 frames from a file

Feb 2nd, 2017
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2017 Kris Occhipinti.
  4. # http://filmsbykris.com
  5. #
  6. # This program is free software: you can redistribute it and/or modify  
  7. # it under the terms of the GNU General Public License as published by  
  8. # the Free Software Foundation, version 3.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18.  
  19. if [ $# -lt 1 ]
  20. then
  21.   echo "Usage: $0 <video file>"
  22.   echo "Example: $0 'myvideo.mp4'"
  23.   exit 1
  24. fi
  25.  
  26. video="$1"
  27. number=100
  28. frames="$(ffprobe -v error -show_format -show_streams  "$video"|grep nb_frame|cut -d\= -f2)"
  29. fs="$(echo "${frames}/100"|bc)"
  30.  
  31. echo "There are $fames frames in the file."
  32. echo "Extracting a frame ever $fs frames to get $number frames."
  33. sleep 1
  34.  
  35. ffmpeg -i "$video" -vf "select=not(mod(n\,$fs))" -vsync vfr -q:v 2 img_%03d.jpg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement