Re: YUV Overlay
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 tmur...@wumpus-cave.net: 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
Re: YUV Overlay
Can we run this with out needing ARDdrone? On Wed, Jul 24, 2013 at 8:22 AM, tmur...@wumpus-cave.net wrote: Short on time at the moment, but I have the complete code on a github repo: https://github.com/frezik/UAV-**Pilothttps://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 tmur...@wumpus-cave.net: 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.htmlhttp://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
Re: YUV Overlay
Yes. For my own testing purposes, it's not always convenient to connect to the ARDrone, so I overrode much of the behavior in Mock classes. For decoding the video stream to a file, you can do: $ uav_video_dump --in t_data/ardrone_video_stream_dump.bin --out /tmp/ardrone_video_stream_dump.h264 And then play the out file in a mplayer or vlc. Mplayer might need you to manually set the -fps option (set to 25, I think), or it will mangle the output. Playing the video in real time should work with: $ uav_video_display --in t_data/ardrone_video_stream_dump.bin Which should pop up the SDL window, and then dump a bunch of error messages to the console. This is the one I'm trying to get working here. Thanks, Timm On 24.07.2013 08:17, Kartik Thakore wrote: Can we run this with out needing ARDdrone? On Wed, Jul 24, 2013 at 8:22 AM, tmur...@wumpus-cave.net wrote: Short on time at the moment, but I have the complete code on a github repo: https://github.com/frezik/UAV-Pilot [2] 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 [3]: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 tmur...@wumpus-cave.net: 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 [1] 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 Links: -- [1] http://dranger.com/ffmpeg/tutorial02.html [2] https://github.com/frezik/UAV-Pilot [3] tel:24.07.2013%2001
Re: YUV Overlay
I've made a simplified, standalone example: http://pastebin.com/dPPNc8VL The big array at the top is a single YUV420P frame. Expected behavior is to display that frame in a window for 5 seconds, and then quit. If I comment out the overlay handling, it displays a green background. I've verified that I'm running SDL 2.540. Thanks, Timm On 24.07.2013 08:17, Kartik Thakore wrote: Can we run this with out needing ARDdrone? On Wed, Jul 24, 2013 at 8:22 AM, tmur...@wumpus-cave.net wrote: Short on time at the moment, but I have the complete code on a github repo: https://github.com/frezik/UAV-Pilot [2] 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 [3]: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 tmur...@wumpus-cave.net: 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 [1] 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 Links: -- [1] http://dranger.com/ffmpeg/tutorial02.html [2] https://github.com/frezik/UAV-Pilot [3] tel:24.07.2013%2001