I'm working on a project involving decoding h.264 video frames with ffmpeg and then outputting them to an SDL surface. From what I've read, the YUV overlay is meant for this kind of job, but I'm having trouble getting it to work with the Perl bindings.

One thing that seems odd to me in the Perl docs is:

    As of release 2.3 direct right to overlay is disable.

Besides the typos, this troubles me because it seems that disabling the feature makes the YUV overlay completely useless.

Not to be deterred, I wrote this code:

    SDL::Video::lock_YUV_overlay( $overlay );
    # The order of array indexen is correct, according to:
    # http://dranger.com/ffmpeg/tutorial02.html
    my $pitches = $overlay->pitches;
    $$pitches[0] = scalar @{ $last_vid_frame[0] };
    $$pitches[2] = scalar @{ $last_vid_frame[1] };
    $$pitches[1] = scalar @{ $last_vid_frame[2] };
    my $pixels = $overlay->pixels;
    $$pixels[0] = $last_vid_frame[0];
    $$pixels[2] = $last_vid_frame[1];
    $$pixels[1] = $last_vid_frame[2];
    SDL::Video::unlock_YUV_overlay( $overlay );

    SDL::Video::update_rects( $sdl, $bg_rect );
    SDL::Video::display_YUV_overlay( $sdl, $bg_rect );

When I run this, I get an error about not being able to find the pitches() method against the class "SDL::Overlay". Eh? (Same thing happens for the pixels() method if I put that call first.) I can call width() and format() and such just fine on that object.

If needed, I can handle the overlay entirely at the C level. I may end up doing that anyway; the C array that comes out of ffmpeg is being transformed into a Perl array-of-arrays, which is going to be an expensive operation to do for 720p at 30 fps in realtime. But I'd like to try this at the Perl level for now.

I might also have to convert the output from ffmpeg using sws_scale(). It's coming out in YUV420P mode, and I'm using YV12 to init the overlay. But I'd like to get the above working before messing with that.

Timm Murray

Reply via email to