[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: MODULE FOR I, P FRAME

Rhodri James

2/11/2010 11:32:00 PM

On Thu, 11 Feb 2010 19:31:52 -0000, DANNY <danijel.gvero@gmail.com> wrote:

> Hello!
>
> I am currently developing a simple video player in python, and my
> problem is that i can't find a module which has a function that can
> determine if frame(image) is I or P coded (MPEG coding). I have been
> using PIL but I couldnt find anything that could help me with that
> problem.

How are you reading the video? PIL doesn't claim to do more than identify
MPEG files. Also, which MPEG encoding, in which container format?

If you aren't just putting a wrapper around something like ffmpeg, I
rather suspect you'll have to decode the bitstream yourself. That could
be rather painful if you're talking about MPEG-4/10.

--
Rhodri James *-* Wildebeeste Herder to the Masses
13 Answers

DANNY

2/14/2010 10:08:00 AM

0

Hy, first thanks for your response!
Well I am thinkin on coding in MPEG4/10, but I would just encode the
video in that encoding,
then stream it with VLC and save the video file on my disc. Then I
would play it with my player....I was thinking on using the image
iterator in PIL...because I would encode the video in GoP of 10 (one I
and 9P), and then I would manipulate it within the sequence...so I
dont have to have a special decoder, because the VLC would already
decode it.

Rhodri James

2/15/2010 10:54:00 PM

0

On Sun, 14 Feb 2010 10:07:35 -0000, DANNY <danijel.gvero@gmail.com> wrote:

> Hy, first thanks for your response!
> Well I am thinkin on coding in MPEG4/10, but I would just encode the
> video in that encoding,
> then stream it with VLC and save the video file on my disc. Then I
> would play it with my player....

I think you're misunderstanding what VLC does here. Saving the video file
should preserve format by default; you may be able save it out in YUV
format (I don't have a copy on this machine to check), but that will take
up ludicrous amounts of disc space and you'd still have to write a byte
reader for it. If you do do that, you have lost any chance of knowing
whether a frame was an I or P frame in the original format, not that it
matters anyway by that point.

MPEG-4/10 is hard to write efficient decoders for, and I have to admit I
wouldn't do it in Python. You'd be better off writing a wrapper for one
of the existing MP4 libraries.

--
Rhodri James *-* Wildebeeste Herder to the Masses

DANNY

2/16/2010 7:15:00 AM

0

On Feb 16, 12:53 am, "Rhodri James" <rho...@wildebst.demon.co.uk>
wrote:
> On Sun, 14 Feb 2010 10:07:35 -0000, DANNY <danijel.gv...@gmail.com> wrote:
> > Hy, first thanks for your response!
> > Well I am thinkin on coding in MPEG4/10, but I would just encode the
> > video in that encoding,
> > then stream it with VLC and save the video file on my disc. Then I
> > would play it with my player....
>
> I think you're misunderstanding what VLC does here.  Saving the video file  
> should preserve format by default; you may be able save it out in YUV  
> format (I don't have a copy on this machine to check), but that will take  
> up ludicrous amounts of disc space and you'd still have to write a byte  
> reader for it.  If you do do that, you have lost any chance of knowing  
> whether a frame was an I or P frame in the original format, not that it  
> matters anyway by that point.
>
> MPEG-4/10 is hard to write efficient decoders for, and I have to admit I  
> wouldn't do it in Python.  You'd be better off writing a wrapper for one  
> of the existing MP4 libraries.
>
> --
> Rhodri James *-* Wildebeeste Herder to the Masses


Hm, well I see that and now I am thinking of using reference software
for MPEG4/10 which is written in c++ http://iphome.hhi.de/sue...
just to use it as a decoder on my client side, save the file in that
format and then play it in my player using pyffmpeg
http://code.google.com/p... and just manipulate frames in that
clip-I think that could be possible....am I right? Thanks for your
help!

Tim Roberts

2/18/2010 8:07:00 AM

0

DANNY <danijel.gvero@gmail.com> wrote:
>
>Hm, well I see that and now I am thinking of using reference software
>for MPEG4/10 which is written in c++ http://iphome.hhi.de/sue...
>just to use it as a decoder on my client side, save the file in that
>format and then play it in my player using pyffmpeg
>http://code.google.com/p... and just manipulate frames in that
>clip-I think that could be possible....am I right?

After you have passed the video through a decoder, it's no longer in MPEG
format at all. It's just a series of bitmaps, so pyffmpeg wouldn't apply.

If you want to save the raw MPEG data, you can certainly do that, but such
data is often not divided into "frames".
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

DANNY

2/18/2010 9:50:00 AM

0

If I want to have a MPEG-4/10 coded video and stream it through the
network and than have the same video on the client side, what should I
use and of course I don't want to have raw MPEG data, because than I
couldn't extract the frames to manipulate them.

Rhodri James

2/19/2010 1:12:00 AM

0

On Thu, 18 Feb 2010 09:50:14 -0000, DANNY <danijel.gvero@gmail.com> wrote:

> If I want to have a MPEG-4/10 coded video and stream it through the
> network and than have the same video on the client side, what should I
> use and of course I don't want to have raw MPEG data, because than I
> couldn't extract the frames to manipulate them.

By the looks of it, pyffmpeg may have some support for streamed input. If
not, you might be able to put something together from tstools
(http://developer.berlios.de/project...) -- it's not what the tools
were intended for, but there are Python bindings to the libraries that
might help depending on exactly how you are streaming your video.
Unfortunately the documentation is sparse to put it mildly, and pyffmpeg
makes tstools look positively informative about how you're supposed to use
it.


--
Rhodri James *-* Wildebeeste Herder to the Masses

Tim Roberts

2/20/2010 11:55:00 PM

0

DANNY <danijel.gvero@gmail.com> wrote:
>
>If I want to have a MPEG-4/10 coded video and stream it through the
>network and than have the same video on the client side, what should I
>use and of course I don't want to have raw MPEG data, because than I
>couldn't extract the frames to manipulate them.

If you want to manipulate the frames (as bitmaps), then you have little
choice but to decode the MPEG as you receive it, manipulate the bitmaps,
and re-encode it back to MPEG.

That's going to take a fair amount of time...
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

DANNY

2/22/2010 10:49:00 AM

0

On Feb 21, 1:54 am, Tim Roberts <t...@probo.com> wrote:
> DANNY <danijel.gv...@gmail.com> wrote:
>
> >If I want to have a MPEG-4/10 coded video and stream it through the
> >network and than have the same video on the client side, what should I
> >use and of course I don't want to have raw MPEG data, because than I
> >couldn't extract the frames to manipulate them.
>
> If you want to manipulate the frames (as bitmaps), then you have little
> choice but to decode the MPEG as you receive it, manipulate the bitmaps,
> and re-encode it back to MPEG.
>
> That's going to take a fair amount of time...
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

Yes, well beside bieng time-consuming, that is also inappropriate for
me,
because I want to have clip that would be streamed across the network
and
have the same GoP on the client side as the original-because I want to
see
what is the effect of errors on different GoP sizes. I would
manipuleta the
received clip just in the way that (if there are too many errors) I
would
stop displaying untill the next I frame.....I cant find a way to do
that....is there a way?

Rhodri James

2/23/2010 12:20:00 AM

0

On Mon, 22 Feb 2010 10:48:55 -0000, DANNY <danijel.gvero@gmail.com> wrote:

> On Feb 21, 1:54 am, Tim Roberts <t...@probo.com> wrote:
>> DANNY <danijel.gv...@gmail.com> wrote:
>>
>> >If I want to have a MPEG-4/10 coded video and stream it through the
>> >network and than have the same video on the client side, what should I
>> >use and of course I don't want to have raw MPEG data, because than I
>> >couldn't extract the frames to manipulate them.
>>
>> If you want to manipulate the frames (as bitmaps), then you have little
>> choice but to decode the MPEG as you receive it, manipulate the bitmaps,
>> and re-encode it back to MPEG.
>>
>> That's going to take a fair amount of time...
>> --
>> Tim Roberts, t...@probo.com
>> Providenza & Boekelheide, Inc.
>
> Yes, well beside bieng time-consuming, that is also inappropriate for
> me,
> because I want to have clip that would be streamed across the network
> and
> have the same GoP on the client side as the original-because I want to
> see
> what is the effect of errors on different GoP sizes. I would
> manipuleta the
> received clip just in the way that (if there are too many errors) I
> would
> stop displaying untill the next I frame.....I cant find a way to do
> that....is there a way?

Could you say a bit more about what you mean when you say "the effect of
errors"? It's easy enough to introduce bit errors into a data file (just
flip random bits), but I'm not clear what it is you're trying to measure.

--
Rhodri James *-* Wildebeeste Herder to the Masses

Tim Roberts

2/23/2010 5:11:00 AM

0

DANNY <danijel.gvero@gmail.com> wrote:
>
>Yes, well beside bieng time-consuming, that is also inappropriate
>for me, because I want to have clip that would be streamed across
>the network and have the same GoP on the client side as the
>original-because I want to see what is the effect of errors on
>different GoP sizes. I would manipuleta the received clip just
>in the way that (if there are too many errors) I would
>stop displaying untill the next I frame.....I cant find a way to do
>that....is there a way?

Sure. You can do a partial decode yourself, scan for the start of frame
markers, pull the I/P/B state from that, and periodically "forget" to pass
the buffer through. Your filter could have MPEG in and out.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.