A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] External video is displayed at wrong dimensions?

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Posts
    133

    resolved [RESOLVED] External video is displayed at wrong dimensions?

    All,

    I was working through the example AS code in Adobe's documentation:

    http://help.adobe.com/en_US/ActionSc...0204-7d4e.html

    Usually, when working with video, I use the FLVPlaybackComponent, but for this project I don't really need any fancy skins/features, I just need to load and play an external video.

    Anyway, I have a .MP4 video that when I right-click and look at its properties... its dimension is 640x480.
    However, when I try and test the code below:
    Actionscript Code:
    var nc:NetConnection = new NetConnection();
    nc.connect(null);

    var ns:NetStream = new NetStream(nc);
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    ns.play("CNN_Anderson_Cooper.mp4");
    function asyncErrorHandler(event:AsyncErrorEvent):void
    {
        // ignore error
       
    }

    var vid:Video = new Video();
    vid.attachNetStream(ns);
    addChild(vid);
    The video appears at the top-left corner of the stage... but it is only 320x240

    This isn't a big deal right now, because I can just add this after the fact:
    Actionscript Code:
    vid.width=640;
    vid.height=480;

    But, that's not the ideal solution... and it just seems like strange behavior for Flash to arbitrarily show video at half-size, so I have a feeling I'm doing something wrong or missing something?

  2. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    9
    Code:
    var nc:NetConnection = new NetConnection(); 
    nc.connect(null);
    
    var ns:NetStream = new NetStream(nc); 
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 
    function asyncErrorHandler(event:AsyncErrorEvent):void 
    { 
        // ignore error 
        
    }
    
    var vid:Video = new Video(); 
    vid.attachNetStream(ns); 
    addChild(vid);
    
    ns.client = new Object(); 
    ns.client.onMetaData = function(info:Object) {
    	vid.width = info["width"];
    	vid.height = info["height"];
    }
    
    ns.play("CNN_Anderson_Cooper.mp4");
    Or you could extend the NetStream class and add onMetaData method.

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Posts
    133
    Guess I should've been clearer about my question... I know there's a dozen ways I can re-size the video, but it just seems like I shouldn't HAVE to manually set the width and height of the video if I just want it to be 100% of the ACTUAL width and height of the .mp4 or .flv file.

    So, my question is:
    When loading an external video asset using basic, basic code... is the "default" behavior of Flash/AS3.0 to load the video at 50% of its actual resolution??

    If so, what the hell? I would love to hear a reasonable explanation if anyone has one... is this just a side-effect of NOT using the FLV Component?

    (I think) Flash doesn't treat JPGs like this... e.g. if you loaded a 1000x1000 pixel JPG onto a 500x500 stage... the JPG would bleed off and you would only see the top-left quadrant.
    Fash wouldn't just say:
    "Hey, I know you told me to load this 1000x1000 JPG, but you don't know what you REALLY want... so here's the JPG at 50%.... HA!"
    Really, it's not that big of a deal... but I just want to know WHY?
    Last edited by badaboom55; 04-15-2010 at 01:10 PM.

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Posts
    133
    Ok... so at first I thought Flash was re-sizing my video to 50%, but after further testing Flash appears to try and re-size video to 320x240, regardless of the dimensions/aspect ratio of the external file!

    I tried loading a 100x100 video, and Flash placed it on the stage, and re-sized it to 320x240.
    I tried loading a 1280x720 video and achieved the same result.

    WHERE IS THE 320x240 SIZE COMING FROM!?

    Is this size DOCUMENTED/CHANGEABLE somewhere?

    Or, is this just an arbitrary size that the Adobe Developers decided to "hardcode" into AS3 framework when dealing with video, thus forcing developers to explicitly tell the Flash engine if they want the video to display at something OTHER than 320x240???

    I just want to make sure I'm not writing bad code, or using bad practices.

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Posts
    133
    Gadzooks! Found where the 320x240 size was coming from...

    Apparently the constructor of the Video class has two optional parameters, width and height, that have default values of 320 and 240 respectively:
    http://help.adobe.com/en_US/AS3LCR/F...dia/Video.html

    So, when creating an instance of the Video class:

    Actionscript Code:
    var vid:Video = new Video(); // creates a 320x240 video
    var vid:Video = new Video(960, 540); // creates a 960x540 video

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center