Automatic sampling of video files: easier said than done!

By jayvol09 on Friday 2 November 2012 11:26
Category: -, Views: 1.719

Keywords: automatic sequential frame image extraction dumping

Recently, as part of my research, I needed to extract a frame every x seconds from a video shot with a panasonic camcorder. Turns out there's not a lot of programs that can do this, or at least not many that advertise this feature. Software I found:
  • Frameshots (by
  • Free video to Jpeg converter (by dvdvideosoft) - free
  • Imagegrab (by hobbyist Paul Glagla) - free
  • Advanced X video converter (by AoA)
X video converter does more than extract images, but this is one of it "modes". It doesn't support mkv, MTS or M2TS containers. It outputs various common image formats and lets the user input a start and end time for capturing from the video. Also allows a resize filter. Its main output formula are:
  1. Sample X images per second (X integer) - allows a high temporal frequency, can't go lower than X = 1.
  2. Sample 1 image per X frames (X integer) - variable framerate can mess up things here
Of course I have to assume the first option does handle variable framerates, though as a user I don't actually know if the time is calculated based on average fps, extracted from some timecode or some other method. Also, if capturing several pictures per second, I have to assume the sampling is evenly spaced over the course of the second.
It is clear that with constant framerate video these 2 options combined with start / end parameters should offer complete (temporal) control over the extracted sequence. The first allows arbitrary high sampling from 1Hz upwards, the second allows sampling under 1 Hz.

Imagegrab is focused on the objective of saving images from video. Basic filters (flips and watermarks), and its intervalometer offers the same 2 options as X vid converter. It doesn't have start / end parameters or resizing. It does allow changing the second unit to minutes and realtime playback during capture. The latter feature helps with visual confirmation that sampling occurs on at the right times.

Frameshots, a commercial attempt at niche software. It thought my 1920x1080i video was 1920x746 in the preview window. Is it coincidence that 1080/746 = a common pixel aspect ratio?- I digress. But once I started outputting it could do 1920x1080. It worked properly with a different test file (avi). It allows cropping, brightness and contrast filters. Sequence parameters include start and end time. Its interval options are:
  1. 1 sample per X miliseconds (X integer > 0)
  2. X images per video clip (I'm assuming equal spacing)
Effectively allowing sampling up to 1000Hz, with no lower limit.
In all I felt it was picky regarding codecs and it froze once for no clear reason. It does offer miliseconds as unit of time which is smart considering the timescale of frames, but offers no extra control.

Dvdvideosoft's free video to JPEG converter gives a simple interface, no filters.
Options are: 1 Sample every X frames, 1 Sample every X seconds, X Samples from total video. Again only X as positive integer values.
No big difference from the others in sequence freedom here, again no start/end time. However I would like a .bmp option.

Alternatively many editors and converters sport an imagedump output option, but that gives you every frame of the final video as an image. Even if you can be bothered to delete all the unneeded ones it gets complicated if your video has a variable framerate or drivespace is limited.
A slower but less error-prone approach is to just manually select the frames in a player or editor, since most have a "save as .bmp / .tiff / .jpeg /. png" option. You could maybe even pick a frame just before or after the frame at the timepoint, if the quality is better and the time accuracy loss isn't vital. But not very practical when analyzing long videos or at a high temporal resolution.

In conclusion:
I didn't pay much attention to the naming formats available as this can often be easily corrected or isn't important. Imo an important feature is having a start & end time parameter, makes life easier. A help file that details exactly (and perhaps graphically) how the extraction is done may help alleviate some of my concerns regarding variable frame rate and equal spacing of samples.
Perhaps ironically, only the 2 free software options allowed MTS files, where I had to remux first for the other 2 ( 3/4 could handle mkv, they all handled .mp4 and .mov). This remuxing brings its own problems, more on that later.

Volgende: Codec Hell: Change video container without encoding 11-'12 Codec Hell: Change video container without encoding
Volgende: Common Video Editors Lack of Control is Painfully Evident: PiP case 11-'12 Common Video Editors Lack of Control is Painfully Evident: PiP case


Comments are closed