Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I need to get still images from an MPEG file (.mpg extension), in sequential order.

I have looked up the Web and MSDN Library but found no suitable solution. I had used Video for Windows and IMediaDet in the past for this task on .avi files, but they don't support my MPEG files.

I want something as simple as it deserves to be, preferably using standard .NET features.

Ideally,
FrameReader* Reader= new FrameReader("MyFile.mpg");
while (Reader.NextFrame())
{
    Bitmap* Frame= Reader.GetFrame();

    ...
}
Reader.Close();

rather than headaches coding with DirectX or similar. (All right, I know I am dreaming, but I am sure there are solutions under the 200 lines of code.)
Posted
Comments
TRK3 13-Sep-12 18:29pm    
There are open source mpeg decoding libaries. Most of them are going to be written in C. Are you willing to deal with mixed native / managed code?
YvesDaoust 14-Sep-12 2:20am    
I don't mind mixing native and managed code. I am looking for a solution that I can put at work in a couple of hours. Can you recommend me one that has a straightforward API?
YvesDaoust 14-Sep-12 3:08am    
I made an attempt with FFmpeg and quickly ran into portability problems with the MSVC environment (missing include files, vararg macros...), all requiring ad-hoc adaptations at various places.

This is exactly what I want to avoid. Dealing with such mammuth packages is a pain in the neck.
TRK3 14-Sep-12 13:35pm    
I haven't used one in a Windows environment. I had a relatively painless experience with a FFmpeg library in an iOS environment -- but I found one that had been specifically ported to that environment and was pleasantly surprised to find that it built without my having to do anything.

Unless someone else has already done the port to Windows and you can just download it and build it, it does become rather precarious pretty fast.

Somebody must have a suggestion though.
YvesDaoust 14-Sep-12 14:06pm    
I made yet another attempt with the FilgraphManagerClass object. It has all the bells and whistles I need, like RenderFile, Run, Pause, GetCurrentImage, CurrentPosition...

Unfortunately, I found no way of getting frame-by-frame resolution :(

1 solution

Did you look at this before:
Extract Frames from Video Files[^]
 
Share this answer
 
Comments
YvesDaoust 14-Sep-12 2:25am    
No I didn't, thank you for pointing me at it.

Unfortunately, I tried the IMediaDet interface and it does not work with my file. It just reports 0 output streams in it.

This is confirmed by the Demo application that comes with the article.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900