Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing bitmapData from a video display playing a h.264 (mp4) video

I have a video file which I play in an Android air app. I'm trying to capture a frame using bitmapData.Draw(video), but it works only for .flv video.

The videos are played locally - no internet or server.

Once I change the video to an .mp4, it plays it on stage, but has a blank bitmapData after the draw function is called. I doesn't say any error.

How can I capture a frame from the played .mp4 video?

Note - It's a Video component, not a StageVideo, since I know it's impossible with StageVideo.

The net stream initialization. I also added the checkPolicyFile = true - it didn't help.

my_nc.connect(null);
my_nc.client = this;

_ns = new NetStream(my_nc);
_ns.client = this;
_ns.useHardwareDecoder = true;
_ns.checkPolicyFile = true;
like image 962
mik Avatar asked Oct 06 '22 06:10

mik


1 Answers

UPD: It seems there isn't way to draw h.264 video in bitmap on android devices by ActionScript. I tested this demo(sources) with this h.264 encoded video file (It's origin) in mp4 container in mobile FlashPlayer 11.1 and in AIR 3.5 application with the same code and both of them have failed. I've got the black rectangle in all render modes (direct, cpu and gpu).

The possible workaround can be to write the native extension making screenshot (I found this one, but it's reported can crash you app, but sources can be helpful) and crop the video by known rectangle. It's not a beautiful solution, but I don't see the other variants for now.

like image 99
fsbmain Avatar answered Oct 13 '22 11:10

fsbmain