7 Replies Latest reply on Feb 27, 2012 8:17 AM by adninjastrator

    Difficulty using hardcoded swf file to display flv files



      I have created a swf player using the flvplayback component to display flv files. The document in flash is 275 pixels wide by 130px pixels long. I also have my video component (flyPlayBack) set at 275px by 100px to display the playback controls. My flash code is my simple like the following

      import fl.video.*;

      var myflashvars:Object = new Object();

      myflashvars = this.loaderInfo.parameters;

      var fullVideoPath:String = "";


      for (var item:String in myflashvars)


          if(item == "filename")


              fullVideoPath = myflashvars[item];



      videoPlayer.source = fullVideoPath;


      So using the above it should play the video and does.

      (1) First question is I tried playing 2 different videos in my html code.

      <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='275' height='130'>
      <param name='allowFullScreen' value='true' />
      <param name='movie' value='moviePlayer.swf' />
      <param name='wmode' value='window' />
      <param name='scale' value='showall' />
      <param name='flashvars' value='filename=sample_sorenson2.flv' />
      <embed width='275' height='130' allowFullScreen='true' type='application/x-shockwave-flash' src='moviePlayer.swf' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='window' scale='showall' flashvars='filename=sample_sorenson2.flv' />

      Just like above works fine. But I tried playing 2 different videos, the first video image is below


      The second video image is below


      I notice the video sizes are different but not the video player size, is this to do a thing called aspect ratio? Is it possible to change this using my simple actionscript code above?

      (2) I also tried the full screen button but the video only takes up part of the screen, as shown below. sorry about image size.


      Is this a common occurance, is there a way to access the buttons on the flyplayback instance using actionscript and overridding the behaviour? Any advice upon my current situation would be much appreciated. Thanks.

        • 1. Re: Difficulty using hardcoded swf file to display flv files
          adninjastrator Level 4

          You can't just set a video player size without considering the aspect ratio of the videos you intend to play.

          Most video camera will shoot either wide screen 16:9 aspect ratio or 4:3 standard def aspect ratio.

          Your choice of 275 x 100 is neither.. that's way the videos do not fill the entire video player.

          Black bars on the sides of a video mean that the HEIGHT of the display is not high enough to let the video stretch all the way out to the sides of the display.

          Black bars on the top and bottom of a video means the WIDTH of the diplay is not wide enough to let the video strectch all the way to the top and bottom of the display.

          A 16:9 aspect ratio video diplayed at 275 px wide should be 275/16 = 17.19, 17.19 x 9 = 154.71 px high

          A 4:3 aspect ratio video displayed at 275 px wide should be 275/4 = 68.75, 68.75 x 3 = 206.25 px high


          See why its best not to use such odd width...fractional pixels don't work well... use something divisible by 8.

          So to determine height... take your desired width and divide by 16 (or 4) and take that number times 9 (or 3).... depending on the video aspect ratio.

          Best wishes,


          • 2. Re: Difficulty using hardcoded swf file to display flv files
            marctheman Level 1

            Thanks for the reply very useful information. Just have quick question, if 1 looks at the first 2 screenshots, the video player seems to scale along with the video playing inside it. I just used the flyplayback control for this with a hardcoded video string name. Just wondering if I created a seperate video player using buttons, images, etc on the stage and not just the builtin flyplayback feature, should it be possible that my video player size be a standard size (not changing) but the actual video size itself can change? This is the approach I reckon I need but I will have to code all the buttons, including the full-screen one. Thanks.

            • 3. Re: Difficulty using hardcoded swf file to display flv files
              adninjastrator Level 4

              To me the first two screen shots look like you set the wrong aspect ratio/screen size. I don't see any scaling of the player at all... only black bars on sides because the video didn't fill the entire video player display.

              And yes, there is a much more powerful and versatile means of displaying Flash video, called NetStream. You can design your own player and have better control over the display. I always use NetStream rather than the FLVPlayback.

              But if you are having sizing issues introduced during the creation of the video... then the player itself is not necessarily going to fix that. You need to know the correct display size and aspect ratio for each video you plan to display.

              However, you can somewhat adjust the display size for each video using some actionscript... as you see here:


              an example of a larger (high brandwidth) version and a smaller (lower bandwidth) version... depending on which button you click.

              More on NetStream:

              http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.htm l

              Here is a great tutorial on building your own NetStream video player:


              scroll to the very bottom of the page "Video Basics"

              Best of luck!


              • 4. Re: Difficulty using hardcoded swf file to display flv files
                marctheman Level 1

                Thanks for all the useful information, excellent tutorials. Just wondering is there a way to get a flv files width and height? I have read the following:

                http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/FLVPlayback.ht ml#preferredHeight

                It says to use the preferredHeight value to get an flv's height when the ready event is called.

                When is this ready event called?

                Is it when the video starts playing?

                Or when the video is fully loaded?

                Is it reliable to use? Thanks for all the help much appreciated!

                • 5. Re: Difficulty using hardcoded swf file to display flv files
                  adninjastrator Level 4

                  I do not know how to use "preferred height"... I have never worked with it.

                  However, if I get an .flv file that I did not create and don't  know the original dimensions, I always include this line in my NetStream player:

                  ns.onMetaData = function(myMeta) {
                  for (var i in myMeta) {
                    trace(i + ":\t" + myMeta[i])

                  It will return any meta data embedded into the video file and output in a trace during testing ... for example:

                  canSeekToEnd: true
                  audiocodecid: 2
                  audiodelay: 0.038
                  audiodatarate: 96
                  videocodecid: 4
                  framerate: 29.9699859619141
                  videodatarate: 500
                  height: 338
                  width: 450
                  duration: 19.052

                  So besides the width/height, I can find the frame rate, video/audio bitrate, duration, etc.

                  Then I can set the display dimensions accordingly.

                  Best wishes,


                  • 6. Re: Difficulty using hardcoded swf file to display flv files
                    marctheman Level 1

                    Thank you very much for all the help regarding this. Just wondering if analyzing a flv file that 1 didn't create, when accessing the video metadata, is it guaranteed to have height, width values? Just wondering does this have to be entered by the user who created the video as part of the metadata or can actionscript just detect these values from the video itself? Hope I am making myself clear and it isn't a ridiculous question. Thanks. 

                    • 7. Re: Difficulty using hardcoded swf file to display flv files
                      adninjastrator Level 4

                      There is no guarantee that the video file will have the meta data encoded into it. That is usually done during the encoding process. The better encoding programs like Adobe Media Encoder and most real video editing programs will automatically detect and encode the meta data in the video file. But some "converter" type programs may not be able to read the data and so in effect strip out that data when they "convert" the video file from one format to another.

                      And as far as I know, if that meta data is not already encoded into the video file, there is nothing there for Actionscript to detect.