Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Draw Video cause flickering and return empty BitmapData #87

Open
itlancer opened this issue Aug 25, 2019 · 4 comments
Open

[Android] Draw Video cause flickering and return empty BitmapData #87

itlancer opened this issue Aug 25, 2019 · 4 comments

Comments

@itlancer
Copy link

Problem Description

Draw Video object cause video flickering and return empty BitmapData with Android devices.
There is no way to get video screenshot (draw it to BitmapData).
It has been tested from AIR 25.0.0.134 to latests AIR 32.0.0.144 beta and AIR 33.0.1.228 with different Android devices and Android OS versions. With armv7 and armv8 build targets. Same problem in all cases with different H.264 (MP4) videos.
Also it works fine with AIR 24 or below.
Also it works fine with Windows.
Changing renderMode and containsVideo in application manifest doesn't help.
NetStream::useHardwareDecoder = true doesn't help - video doesn't playback at all (for AIR 33).
<disableMediaCodec>true</disableMediaCodec> doesn't help.

Tracker link: https://tracker.adobe.com/#/view/AIR-4198435

Steps to Reproduce

  1. Launch code below with any Android device and any MP4 H.264 video.
  2. Click anywhere on stage. Video screenshot must appear right after video.

Application example with sources and example of video attached.
video_draw_empty_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Video;
	import flash.events.NetStatusEvent;
	import flash.events.MouseEvent;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	
	public class VideoDrawEmptyBug extends Sprite {
		private var nc:NetConnection;
		private var ns:NetStream;
		private var video:Video = new Video(640, 480);
		private var bitmap:Bitmap = new Bitmap();
		
		public function VideoDrawEmptyBug() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			addChild(video);
			
			bitmap.x = 650;
			addChild(bitmap);
			
			nc = new NetConnection();
			nc.addEventListener(NetStatusEvent.NET_STATUS, ncHandler);
			nc.connect(null);
			
			stage.addEventListener(MouseEvent.CLICK, click);
		}
		
		private function click(e:MouseEvent):void {
			var bd:BitmapData = new BitmapData(video.width, video.height, false, 0x000000);
			bd.draw(video);
			
			bitmap.bitmapData = bd;
		}
		
		private function ncHandler(e:NetStatusEvent):void {
			if (e.info.code == "NetConnection.Connect.Success"){
				ns = new NetStream(nc);
				ns.client = {onMetaData:getMeta};
				ns.addEventListener(NetStatusEvent.NET_STATUS, nsHandler);
				video.attachNetStream(ns);
				ns.play("video.mp4");
			}
		}

		private function nsHandler(e:NetStatusEvent):void {
			trace(e.info.code);
			if (e.info.code == "NetStream.Play.Stop"){
				ns.play("video.mp4");
			}
		}

		private function getMeta(mdata:Object):void { }
	}
}

Actual Result:

  1. Video flickers
  2. Screenshot black (BitmapData background). Screenshot "empty".

Expected Result:
Display correct video screenshot (BitmapData) without flickering.

Known Workarounds

none (below AIR 33 NetStream::useHardwareDecoder = false but it cause performance problems)

@itlancer
Copy link
Author

Issue still exists with latest AIR 33.1.1.50.

@itlancer
Copy link
Author

Issue still exists with latest AIR 33.1.1.98.

@itlancer
Copy link
Author

Bug still exists with latest AIR 33.1.1.620.

@itlancer
Copy link
Author

Issue still exists with latest AIR 51.1.1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant