Home > Archive > Unix Programming > January 2005 > mpeg2 read frame using C or C++ or Matlab
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mpeg2 read frame using C or C++ or Matlab
|
|
| b83503104@yahoo.com 2005-01-23, 8:58 pm |
| Is there any source/library to read single frames from MPEG-2, and save
them as images? Converting the whole MPEG-2 video to other more
supported formats (such as .avi) occupies too much disk space.
Thanks
| |
| Bernie 2005-01-24, 3:58 am |
|
<b83503104@yahoo.com> a écrit dans le message de
news:1106506437.088185.108040@z14g2000cwz.googlegroups.com...
> Is there any source/library to read single frames from MPEG-2, and save
> them as images? Converting the whole MPEG-2 video to other more
> supported formats (such as .avi) occupies too much disk space.
> Thanks
Hi, i know that manage video under lossless format can be difficult.
Working in a video team, i have build a lib from VirtualDubMod source code
dedicated to Mpeg file of elementary video and program stream decoding, it
lead to get video frame in YUV422 raw format.....
you can find it on my web site (a french site so look in the news section 2
link added today)
http://berniedev.tripod.com/berniedev_site/Index.htm
It's a C++ Static lib develop under VStudio 03,
Look at ClassMpeg to API...And the 2 file CMPEGVideoFile .cpp and .h to
sample....
good luck
| |
| Piotr Stanczyk 2005-01-24, 8:57 am |
| Have a look at this C suite:
http://ffmpeg.sourceforge.net/index.php
there are some example binaries that you can use/modify to do what you want.
Piotr
b83503104@yahoo.com wrote:
> Is there any source/library to read single frames from MPEG-2, and save
> them as images? Converting the whole MPEG-2 video to other more
> supported formats (such as .avi) occupies too much disk space.
> Thanks
>
| |
| b83503104@yahoo.com 2005-01-25, 3:57 am |
| Thanks for the pointer to ffmpeg, I successfully compiled it on linux.
However, I can't figure out how to extract a single frame, say, frame
number 5593 from a video. Can you help? Thanks!
| |
|
| On 24 Jan 2005 20:16:27 -0800, "b83503104@yahoo.com"
<b83503104@yahoo.com> wrote:
>Thanks for the pointer to ffmpeg, I successfully compiled it on linux.
>However, I can't figure out how to extract a single frame, say, frame
>number 5593 from a video. Can you help? Thanks!
You need to modify it to s through the file for the GOP that
contains the frame you are after, then step through, decoding as you
go, from the previous I-frame until you have the frame you want. It's
not possible with MPEG to decode only 1 frame, since the temporal
compression means you may need 1 or more previous frames and 0 or more
future frames to generate the single frame you are after. Because
MPEG is a streaming format, the frames may not be numbered as you
expect either - you may need to count the frames in each GOP as you go
through the file adding them up 'til you get to the one you want.
Jim
| |
| Pete Fraser 2005-01-25, 4:00 pm |
|
"Jim" <spam@ihug.com.au> wrote in message
news:amjbv0l49dfn799erhubpeovcu2qncsmd8@
4ax.com...
> On 24 Jan 2005 20:16:27 -0800, "b83503104@yahoo.com"
> <b83503104@yahoo.com> wrote:
>
>
> You need to modify it to s through the file for the GOP that
> contains the frame you are after, then step through, decoding as you
> go, from the previous I-frame until you have the frame you want. It's
> not possible with MPEG to decode only 1 frame, since the temporal
> compression means you may need 1 or more previous frames and 0 or more
> future frames to generate the single frame you are after. Because
> MPEG is a streaming format, the frames may not be numbered as you
> expect either - you may need to count the frames in each GOP as you go
> through the file adding them up 'til you get to the one you want.
>
I missed the start of this thread, but if the op wants to extract
a specific frame from an MPEG stream, I think some of the
Elecard software will do it. There are downloadable
demos on their web site. I think what's needed is called
something like StreamEye.
| |
| Bernie 2005-01-25, 4:00 pm |
|
"Pete Fraser" <pete@rgb.com> a écrit dans le message de
news:10vct91t2dhdc58@news.supernews.com...
>
> "Jim" <spam@ihug.com.au> wrote in message
> news:amjbv0l49dfn799erhubpeovcu2qncsmd8@
4ax.com...
>
> I missed the start of this thread, but if the op wants to extract
> a specific frame from an MPEG stream, I think some of the
> Elecard software will do it. There are downloadable
> demos on their web site. I think what's needed is called
> something like StreamEye.
>
>
I think that b83503104 work under linux,
and i'm not sure that Elecard MPEG2 product exist under Linux.
| |
| Bernie 2005-01-25, 4:00 pm |
|
<b83503104@yahoo.com> a écrit dans le message de
news:1106626587.792565.201300@f14g2000cwb.googlegroups.com...
> Thanks for the pointer to ffmpeg, I successfully compiled it on linux.
> However, I can't figure out how to extract a single frame, say, frame
> number 5593 from a video. Can you help? Thanks!
>
as Jim explain, you need to parse your stream and build a list of bitstream
position to each frame...
VirtualDubMod use this tips to acces to all frame with a small decoding
cost, play backward, etc....
| |
| Piotr Stanczyk 2005-01-25, 4:00 pm |
| Jim wrote:
> On 24 Jan 2005 20:16:27 -0800, "b83503104@yahoo.com"
> <b83503104@yahoo.com> wrote:
>
>
>
>
> You need to modify it to s through the file for the GOP that
> contains the frame you are after, then step through, decoding as you
> go, from the previous I-frame until you have the frame you want. It's
> not possible with MPEG to decode only 1 frame, since the temporal
> compression means you may need 1 or more previous frames and 0 or more
> future frames to generate the single frame you are after. Because
> MPEG is a streaming format, the frames may not be numbered as you
> expect either - you may need to count the frames in each GOP as you go
> through the file adding them up 'til you get to the one you want.
>
> Jim
Indeed; there really is no way round this. Other software will simply
provide you with an API that a normal person can get their head round.
This one is a little tricky to start off with.
Piotr
BTW: If you know that your mpg is not of great length and there is a
chance that you will need all the frames then you could decompresss the
lot in the order they come in and save out to a scratch disk or use your
own caching manager. This has clear limitations.
|
|
|
|
|