17

I mean, how to generate images files from a video like screenshots.

23

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.
| improve this answer | |
  • 1
    your link seems be broken – Nolwennig Feb 24 '16 at 9:10
  • @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
  • 5
    -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
  • Thanks, work fine on Xubuntu – Indacochea Wachín Jul 27 '19 at 2:45
3

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.

| improve this answer | |
1

In VLC you can right click, Video, Take Snapshot

| improve this answer | |
  • 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
0

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.