Home > OS >  Extract every nth frame from a MPEG4 using ImageMagick
Extract every nth frame from a MPEG4 using ImageMagick

Time:10-30

I would like to try and extract very nth frame from a large MPEG4 file (20.1MB) that is over 6 minutes long. However if I try something like this:

convert video.mp4 *.png

My entire computer completely crashes. So I would like to try and save some time and computational power by only extracting every nth frame from the MPEG4 file, instead of extracting over 8000 images. How can this be achieved?

CodePudding user response:

I'd use "ffmpeg" to do this. A command to extract PNG images at X intervals can be as simple as this...

ffmpeg -i input.mp4 -r 1 outd.png

Using the option -r 1 will set the output frame rate to 1 every second. Assuming the input video has a frame rate of 25 per second, the option -r 1 will output about every 25th frame. Calculate the interval you need according to the frame rate of the input. For example, to get approximately every 10th frame, use -r 2.5.

The output file name in this example contains d, which creates a numbered sequence with four digits, padded with leading zeros.

CodePudding user response:

VLC Media player can do this:

  1. Run VLC as Administrator.

  2. Click Tools - Preferences in VLC.

  3. Under “show settings”, click “all”.

  4. Under “Video”, select “Filters”, but do NOT expand it yet. Tick the check box “Scene video filter”.

  5. Expand “Filters” and select “Scene filter”,

  6. Give a output path.

  7. set the “recording ratio” box exampe 10,20 etc.

  8. Click “save”.

  9. Click Media - Open Video and find your video. Patiently let the whole thing play. VLC will automatically capture frames and save to the output path.

  10. Disable: Click Tools - Preferences. Under “show settings”, click “all”. Under “video”, select “filters”. uncheck “Scene video filter”. Click “save”.

  • Related