[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] using movieext (patch attached) (fwd)



On Wed, 2 Feb 2005, Rene Dudfield wrote:

> Please resend any patches to my email or to the mailing list, so that

here's a re-send of the little bits i did with pygame.movieext and 
.overlay in January.

1st one makes pygame.movieext work with current ffmpeg (although e.g.  
pymedia seems to use old ffmpeg libs too)

then there are few later tweaks - diffs w/ discussion resent below:
- fix to .get_busy()
- fix to where ffmovie c detects end of video, so that get_busy() works

and adding uses_hw() query to pygame.overlay (patch attached) -- that's 
because the overlay behaves quite differently when it's using hw and when 
not: when using, the overlay goes *under* normal pygame surfaces, but when 
not, it goes on top of them.

i'm sorry there are not better packaged nor too complete (movieext.rewind 
is still flaky etc). do report back about applicability. am not currently 
using the movieext, but pymedia instead, using pygame.overlay (so at least 
getting that little uses_hw() there would be nice)

---------- Forwarded message ----------
Date: Mon, 10 Jan 2005 16:55:58 +0200 (EET)
From: Toni Alatalo <antont@xxxxxxxxxxxxx>
To: pygame-users@xxxxxxxx
Subject: using movieext (patch attached)

(..)

ffmovie.c was doing movie->context->pts_num / movie->context->pts_den; 
which failed 'cause the current (am using ffmpeg from cvs) AVFormatContext 
does not have those structs anymore.

instead, the audio and video streams accessible via that struct now have a 
AVFrac element, which has val, num and den. so that had to be changed to:
movie->video_st->pts.num / movie->video_st->pts.den   .. and
movie->audio_st->pts.num / movie->audio_st->pts.den; (respectively)

going through the ffmpeg cvs history, it seemed that the change was made
latest in May 2004 already (when avifile/avifile-0.6/ffmpeg/ffmpeg.c has
changed in that respect, between revisions 1.86 and 1.87).

(..)

dunno about the ffmpeg versioning issue really, e.g. in which release of 
it that change had been made, but seemed pretty old so i guess it's better 
to be compatible with it. a little patch to do it is attached.

---cut---

From antont@xxxxxxxxxxxxx Wed Feb  2 11:14:05 2005
Subject: Re: [pygame] fix to get_busy() (using movieext (patch attached))

another small but (at least for my app) crucial thing with it:
moviext.Movie is nice enough to implement much of the SMPEG using
movie.Movie interface, so i could simply replace it in this app. however,
.get_busy() was always returning true in error. luckily was easily fixed:

in movieext.c
385c385
<       return PyInt_FromLong(movie->context != NULL);
---
>       return PyInt_FromLong(movie->paused == 0);

---cut---

From antont@xxxxxxxxxxxxx Wed Feb  2 11:14:42 2005
this was still needed for it to work when the end of the movie is reached:

in ffmovie.c line 585 or something:
if (av_read_packet(movie->context, pkt) < 0) {
	ffmovie_stop(movie); /*so that get_busy() will tell has  stopped.. */
	break;
}

an unsolved problem is in .rewind(): it ends up in ffmovie.c's 
ffmovie_reopen, where the surface setting was preserved if the movie 
object had a dest_overlay - i didn't get the logic in that, so changed so 
that dest_surface and dest_rect are always preserved.

this made .rewind() work ok, except in the case where the video has ended 
(and with my change, hence stopped) before the rewind, in which case the 
surface is lost (nothing shows unless set_display is re-done, which is my 
current workaround on the Python side). couldn't find the reason for this.

---end---

~Toni

334c334
<             pts = (double)pkt->pts * movie->context->pts_num / movie->context->pts_den;
---
>             pts = (double)pkt->pts * movie->video_st->pts.num / movie->video_st->pts.den;
356c356
<                     pts = (double)movie->vidpkt_timestamp * movie->context->pts_num / movie->context->pts_den;
---
>                     pts = (double)movie->vidpkt_timestamp * movie->video_st->pts.num / movie->video_st->pts.den;
469c469
<                     pts = (double)movie->audio_pkt_ipts * movie->context->pts_num / movie->context->pts_den;
---
>                     pts = (double)movie->audio_pkt_ipts * movie->audio_st->pts.num / movie->audio_st->pts.den;
125c125,137
< 

---
> 
>     /*DOC*/ static char doc_Overlay_UsesHw[] =
>     /*DOC*/    "Overlay.uses_hw() -> 1 or 0(?)\n"
>     /*DOC*/    "Whether is hw accelerated (1) or not (0?)\n"
>     /*DOC*/    "\n"
>     /*DOC*/    "When using hardware overlay, does not overwrite contents of the display surface.\n"
>     /*DOC*/ ;
> 
> PyObject* Overlay_UsesHw(PyGameOverlay *self)
> {
>   return PyInt_FromLong(self->cOverlay->hw_overlay);
> }
> 
165a178
>   {"uses_hw", (PyCFunction)Overlay_UsesHw, METH_NOARGS, doc_Overlay_UsesHw},