Sign in to follow this  
ouraqt

Video Decoding

Recommended Posts

Hey everyone! I'm looking for a [free] C/C++ library that decodes video files in common formats (preferably at least MPEGs). And by "decode", I just mean I want the ability to get the bitmap data for each frame (so I can save each frame to a file as a separate image, for example, or manipulate it somehow). I don't need to write any video data, just read it. It doesn't really need to be fast or anything (the decoding won't be happening in real time). The library shouldn't output the frames to a window or anything - I just want the bitmap data for each frame. Is there a free library that will do this?

Share this post


Link to post
Share on other sites
_fastcall, I'm looking for a library, not a piece of software. And I'm not in the mood to digest a whole open source application at the moment. I have a feeling a simple library should be able to do this for me. Thanks tho!

mattd, that seems to be more like what I'm looking for. I'll check it out.

Share this post


Link to post
Share on other sites
Quote:
Original post by ouraqt
_fastcall, I'm looking for a library, not a piece of software. And I'm not in the mood to digest a whole open source application at the moment. I have a feeling a simple library should be able to do this for me. Thanks tho!

In _fastcall's defence, you did state that the decoding process can be relatively slow (not real-time), so the easiest method might be to use a pre-existing tool to dump the frames to images (in some easy to read format like BMP or a raw format of some kind), and then load the images up in your code.

Of course this isn't as pretty as using a library directly, but if you're just experimenting or playing around, and don't need to worry about distribution/other users so much, it might be worth considering.

One such tool worth looking at for this is mplayer. It's command-line based, and dumping frames would look something like:
mplayer -vo png foo.mpg
Check this out.

Share this post


Link to post
Share on other sites
if you don't mind non-portability, i think dshow will also do the trick, but it's a messy, COM-based API where figuring out how all your pins need to be connected can drive you crazy. it's been a long time since i've touched dshow, but if you can even suffer with just AVI, VFW can extract frames really easily!

Share this post


Link to post
Share on other sites
Quote:
Original post by yadango
if you don't mind non-portability, i think dshow will also do the trick, but it's a messy, COM-based API where figuring out how all your pins need to be connected can drive you crazy. it's been a long time since i've touched dshow, but if you can even suffer with just AVI, VFW can extract frames really easily!

I would second DirectShow. Note that programming it is hell. It must be one of the most overengineered and chaotic APIs I've ever seen. However, once you got it working, it works really well. A big advantage is that it is actually free. Means that unlike FFMpeg and friends, you are neither bound by an unfree restrictive license (such as GPL or LGPL), nor by any patent issues, since Microsoft basically paid the royalties for you. It is also extensible with tons of external codecs, making your application compatible with virtually every existing format on the planet without much additional work. Of course you will be limited to Windows, which might or might not be an issue.

Share this post


Link to post
Share on other sites
However, I was under the impression that DirectShow is a deprecated API and Microsoft plans to replace it soon.

While I do not need speed per se, I am looking for a moderately robust solution (i.e. actively maintained library). I suppose using something like DirectShow wouldn't be so bad. Can I extract the pixel data from DirectShow directly, without drawing it on the screen or anything?

Quote:
In _fastcall's defence, you did state that the decoding process can be relatively slow (not real-time), so the easiest method might be to use a pre-existing tool to dump the frames to images (in some easy to read format like BMP or a raw format of some kind), and then load the images up in your code.

Of course this isn't as pretty as using a library directly, but if you're just experimenting or playing around, and don't need to worry about distribution/other users so much, it might be worth considering.

Oh, I see. I am trying to make a reusable tool that perhaps others will use as well (although, I am mostly designing it for myself).

Additionally, I think writing all the frames to bitmaps in a folder for a video even only a few minutes long would take a horrendous amount of disk space. This may not be a huge problem because these are only temporary files.

Share this post


Link to post
Share on other sites
Quote:
Original post by ouraqt
Can I extract the pixel data from DirectShow directly, without drawing it on the screen or anything?
There's the Media Detector (MediaDet) object, which can be used to easily extract frames and other information from a file. For more control (and a bit more work setting things up) you could use the Sample Grabber filter (connect it to a null renderer filter so nothing is shown on screen).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this