I mean, how to generate images files from a video like screenshots.
Try with ffmpeg
ffmpeg -i inputfile.avi -r 1 -f image2 image-%3d.jpeg
You can read the documentation here
-i inputfile.avi
The video input file is inputfile.avi-r 1
extract 1 image per second of video. Replace that number for the number of images you want to get per second.-f image2
force image output format, you may probable be able to omit this since the program tries to choose the output images format from the file extension.image-%3d.jpeg
name of the output images, the %3d indicates that the output generated images will have a sequence number there of 3 decimals, if you want the number padded with zeroes you just need to use %03d.
-
1
-
@Nolwennig. Fixed, not as specific as the previous one but at least is the official documentation and hardly to be broken. – YoMismo Jun 23 '16 at 6:41
-
6
-r 1
is for the number of images per sec. So for 60ips, or 24, it's-r 24
. And to limit the extract, it's-ss [start] -t [duration]
. – Sandburg Jun 1 '18 at 21:12 -
I have just downloaded the latest version of VLC for Windows 32 - 2.1.2 Rincewind and it works fine to do this.
Steps:
1 - Click Tools > Preferences and click radio button All
2 - Scroll down and click the + sign next to Video to expand
3 - Scroll down and click on Scene Filter and fill in the info for Directory Path prefix (where you want to save frames). Don't click Save.
4 - Scroll up and click on the word Video under Filters
5 - Click the check box for Scene video filter and click Save.
6 - Open and run a video and it will save .png's
7 - To stop saving frames go back to step 5 and uncheck Scene video filter. Easy really once you know where to find the settings.
-
I had to restart VLC to get changes to the Scene Filter preference to take effect. My platform is macOS; not sure if this applies to Unix/Linux/Win versions. VLC 3.0.11.1. – Mat Gessel Jan 11 at 22:52
In VLC you can right click, Video, Take Snapshot
-
This sounds a bit labour-intensive if one would need images for e.g. each frame in scene. – Kusalananda♦ Oct 6 '19 at 8:06
-
Unfortunately on Linux VLC crashes. (I found postings dating back to 2015, so this is a really old problem) – arved Jan 6 at 11:10
Hope this help
#!/bin/bash
source_dir="."
output_dir="."
input_file_types=(avi wmv flv mkv mpg mp4)
output_file_type="jpg"
convert() {
echo "" | ffmpeg -ss $ss -y -i "$in_file" -an -f image2 -vframes 1 "$output_dir/$out_file"
}
for input_file_types in "${input_file_types[@]}"
do
find "$source_dir" -name "*.$input_file_types" -print0 | while IFS= read -r -d $'\0' in_file
do
echo "Processing…"
echo ">Input "$in_file
# Replace the file type
out_file=$(echo $in_file|sed "s/\(.*\.\)$input_file_types/\1$output_file_type/g")
echo ">Output "$out_file
# get video duration
# fulltime=`ffmpeg -i "$in_file" 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//`;
# hour=`echo $fulltime | cut -d ':' -f 1`;
# minute=`echo $fulltime | cut -d ':' -f 2`;
# second=`echo $fulltime | cut -d ':' -f 3 | cut -d '.' -f 1`;
# seconds=`expr 3600 \* $hour + 60 \* $minute + $second`;
# ss=`expr $seconds / 2`; # from the middle of video
ss=`expr 10`; # from the 10sec of video
# Convert the file
convert "$in_file" "$out_file"
if [ $? != 0 ]
then
echo "$in_file had problems" >> ffmpeg-errors.log
fi
echo ">Finished "$out_file "\n\n"
done
done