roguish

Referencing the Video Instance in OSMF (for BitmapData.draw)

Over-The-Shoulder Quick Tip

Accessing VideoSurface in OSMF is useful if you want to capture a snapshot of the playing video, but it can be difficult to locate the video display object. I found a tip in the comments section of a post by Nils Thingvall that helped:

1
2
3
var tVideoSurface : VideoSurface = ( view.mediaPlayerCore.media.getTrait( MediaTraitType.DISPLAY_OBJECT ) as DisplayObjectTrait ).displayObject as VideoSurface;
var tBitmapData : BitmapData = new BitmapData( tVideoSurface.width, tVideoSurface.height, true, 0 );
tBitmapData.draw( tVideoSurface );

Resource http://nils.realeyesmedia.com/?p=94&cpage=1#comment-875

[UPDATE 03/09/2015] Several readers have reported difficulty capturing BitmapData using this technique despite being able to see the video. If you can play a video but not capture BitmapData from it, chances are you have a problem with security permissions. Check out another post regarding security limitations for help solving that issue: http://www.roguish.com/blog/?p=667.

3 ResponsesLeave one →

  1. christoph

     /  February 21, 2015

    Came across this because I am desperately seeking for a way to capture video frames from an osmf video player i built. playing mp4 video and doing as suggested above, I only get a black rectangle (when transparency = false) with the video’s dimensions.
    also, the “view.mediaPlayerCore” part confuses me — returns an error, whereas my “vPlayer.media. …” does not (but no grabbed image either). hmmmm. do I have to explicitely add the DisplayObject trait beforehand?
    help appreciated, thanks,
    christoph

    Reply
  2. Elliot Mebane

     /  March 9, 2015

    Check out my other post regarding security limitations when trying to capture BitmapData from video (http://www.roguish.com/blog/?p=667). If you can play the video but not capture BitmapData from it, chances are you have a problem with security permissions.

    Reply
  1. Revelens Video Player Platform for Product Placement Purchasing | roguish

Leave a Reply