Re: YUV Overlay
[email protected] Wed, 24 Jul 2013 07:22:27 -0500
| Newsgroups | perl.sdl.devel |
|---|---|
| Message-ID | <[email protected]> |
Short on time at the moment, but I have the complete code on a github repo: https://github.com/frezik/UAV-Pilot The relevant code is in UAV::Pilot::SDL::Video, and the decoding happens in the xs file for UAV::Pilot::Video::H264Decoder. The test t/160_video_decode.t should run the decoding end of things. There's a test video in t_data/ardrone_video_stream_dump.bin, though that contains the PaVE headers from the UAV before each frame. Those headers can be stripped out by bin/uav_video_dump. I'll try to come up with a more concise example later this evening. Thanks, Timm On 24.07.2013 01:00, Tobias Leich wrote: > Hi, can you paste a complete example please? Maybe with a link to a > test > video file. > > What I would try first is SDL's latest release, which is 2.540 or so. > > Cheers, FROGGS > > Am 23.07.2013 23:44, schrieb [email protected]: >> 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. >> >> Thanks, >> Timm Murray