Video cache image extraction fails for short videos

Started by monochrome, February 13, 2025, 10:08:35 PM

Previous topic - Next topic

monochrome

Imatch tries to extract video frames using the following ffmpeg filter (offset = 0, extract just one frame, and time set to one frame every 5 seconds): "-filter:v "fps=1/5(...)""

The purpose of the fps=1/5 is because IMatch wants to extract one frame every 5 seconds, and even though only one frame should be extracted it makes sense to include that parameter and then stop after the first frame.

However, for very short videos (less than 5s), that means ffmpeg drops all frames and nothing makes it to the encoder, and the image extraction fails.

Solution(?): If image extraction fails (or if IMatch knows that the movie file is shorter than the interval between frames it should extract, or if the offset is set larger than the length of the video), IMatch should fall back to extracting the first frame.

Mario

#1
IMatch extracts multiple frames from each video, to support the animated preview in File Window. See help for details and Edit > Preferences > Database for options to control this.

If you have many videos less than 5 seconds (which I would consider unusual), you can tell IMatch to produce one frame per second.

I wonder why you consider this a bug. It's up to you to configure this to match your use case.
You can change the options, process your short videos, then switch back to more normal settings.

Tveloso

There's also the Custom option, which allows us to enter a comma-separated list of second values for the frames to extract.

I recently indexed a few videos that were all 4 seconds or less (one of them just one second long - they were mistaken attempts to take several photos, with the camera accidentally set to video mode).  Despite their short length, I wanted to keep them anyway.

IMatch generated only the "Video Icon thumbnail" for these (because of their short length).

I initially tried using the Bookmark feature in the QuickView Panel, and while that did cause the selected frames to then play in the thumbnail, the thumbnail itself didn't use any of the bookmarked frames.

I then changed the offset to zero, thinking that would result in at least the first frame being picked up as the preview thumbnail, but that didn't seem to work (following a force-update).  But when I used the Custom option, using 1 as the first value in the list, each of those videos then had a preview image following the force update.
--Tony

monochrome

Quote from: Mario on February 13, 2025, 10:20:25 PMI wonder why you consider this a bug.
Because I expect to be able to throw valid media files at a DAM and have it do the sensible thing - which is to generate a thumbnail without having to fiddle with settings, much as I expect IMatch to generate a thumbnail for a 64x64 icon despite having a thumbnail size of, say 256x256.


Mario

I'm not sure how many users have video files less than five seconds.
IMatch processes videos that way since version 2016 or 2017, and you are the first user bringing this up as a problem.

I can add a second pass fallback in case the first pass does not deliver any output image. But as I said, until yesterday, this was never brought up as something users have to deal with.

I guess this will be more common in the future, since it is quite easy now to make a video instead of a photo, when a finger slips on the smart phone. At least on Android, no idea how easy it is to make this mistake on iPhones.


Quotemuch as I expect IMatch to generate a thumbnail for a 64x64 icon despite having a thumbnail size of, say 256x256.
Not sure what you mean by that. Which file format for that icon? .ico or .icox? Single image icon or multi-image / multi-resolution icon? IMatch instructs Windows to extract the largest possible rendition of .ico files and then uses that.
IMatch does not enlarge images smaller than the thumbnail size (standard 300 pixel) I believe. This would produce a really blurry image I believe?`

Mario

The problem is the offset setting. It by default is 2 seconds.
If the offset is beyond the length of the video, no frame is extracted.
I've tested this with videos between 0.5 and 5 seconds, and I got thumbnails for all videos, except the videos shorter than 2 seconds. Do you use the default offset? How long is your video?

I have added an extra test, changing order of operations to determine the duration of the video before generating the command line to send to FFMPEG. If the start offset configured by the user is beyond the length of the video, IMatch shifts it to max(0, length - 1).