Click to See Complete Forum and Search --> : DirectShow iMediaDet not grabbing precise frames


Eddilefey
November 4th, 2004, 12:17 PM
Hi there,

I'm currently coding an application that requires the retrieval of (non-sequencial) indivual frames from avi and mpeg encoded video. My code uses the 'Implement the Frame-Grabbing Function' example from the DShow documentation to grab a bitmap from the video stream using the iMediaDet interface.

As far as I know, the iMediaDet interface cannot grab on a frame basis, so I use the time of the frame instead (time=(desired frame+0.5/framerate)).
(The 0.5 is to avoid trying to grab a frame at the boundary between frame changeover)

To all casual appearances, this works fine.. however, I've found that it returns slightly different frames when grabbing frames from the exact same source (mpeg) files on different media.

This even occurs when I'm trying to grab exactly the same frame, at exactly the same timecode, on an exact copy of the video.. but one copy of the video is located on my hard drive and the other on CD.

The difference is only small (usually only 1 frame), but causes serious problems for my work, which requires consistent frame accuracy. It appears as though some form of approximation is occurring when the frame is being grabbed from the slower CD Rom version of the file.

Has anybody seen this problem before?
Is there a solution?

Any help would be greatly appreciated..

darwen
November 8th, 2004, 11:34 AM
This is not a pleasant problem - I've spend days at work trying to get frame accuracy out of mpegs, avis and wmvs.

I don't use media det to do this : I render the file and insert a sample grabber filter before the video renderer/VMR9.

If you're dealing with MPEGs and AVIs the easiest way of getting frame accuracy is to use the IMediaSeeking interface and set its timing type to FRAMES.

Then this will always be accurate.

Otherwise, you're looking at a very hard slog of working out how to do this. A word from the wise : this stuff is VERY sensitive to rounding errors so I would suggest removing your '+ 0.5' first.

Also the frame rate should be exactly what it is in the mpeg etc e.g. if it is 29.96 then USE 29.96. Not 30.

All floating point should be done as doubles and not floats.

Good luck, you'll need it !

Darwen.

Srcee1
September 20th, 2011, 06:53 AM
And does someone know how to get video resolution (frame width and height) that will work on Macintosh?

Srcee1
September 21st, 2011, 03:36 AM
And does someone know how to get video resolution (frame width and height) that will work on Macintosh?

Can I use some kind of a ffmpeg mono wrapper?