How to convert a batch of videos (#mp4) to images (#jpg) at regular time interval throughout each video.
Just thought I would share a simple script I made in case anyone else needed to do the same. It is by no means battle-hardened but assuming you have sane names for your videos and trust the content it should work fine. Works great on #Ubuntu
on my #GCE
ffmpeg, zip (sudo apt-get install these)
Simply create a new sh file eg script.sh, paste in the below code, and then run:
chmod +x script.sh
To make it executable.
Finally example usage to generate 1 jpg every 1 second in video:
# A simple script to convert all mp4 videos in current folder to jpg frames with
# unique names. Note assumes max frames per video is no more than 999999
# Pass frames per second we wish to render as images. Eg value of 1 would render
#@author Jason Mayes
# 1 frame each second of video.
for i in *.mp4; do
# Replace .mp4 with blank to remove
FILEPREFIX=$(echo $i | sed 's/.mp4//g')
# Generate frames every quarter of a second assuming 25fps
ffmpeg -i "$FILEPREFIX".mp4 -y -an -q 0 -vf fps="$FPS" "$FILEPREFIX"_%06d.jpg
zip -r images.zip *.jpg