13 Replies Latest reply on Sep 16, 2007 6:54 AM by andyulrika_is_back

    Layer Problem with Graphic over WMV

    andyulrika_is_back Level 1
      Can someone please help.

      I've placed a WMV movie on the stage and have tried to place a transparent image, similar to the border of a television, over the movie but the movie always comes to the top when I play the frame.

      Is there a way of keeping the movie underneath the transparent image and save me making up what I actually want in a video editing program or even Flash.

      Any help much appreciated.

      Andy
        • 1. Re: Layer Problem with Graphic over WMV
          Level 7
          James gave you an option in the DOUG forums.

          In general, direct-to-stage members don't layer in the score, they sit
          on top of every other sprite. If you aren't using QuickTime then you
          can't use the mask property, and I don't think #windowsMedia sprites
          play with dts off, so you may have to use a MIAW, or place graphics in
          the video before compressing.
          • 2. Re: Layer Problem with Graphic over WMV
            Applied CD Level 1
            WMV’s and MPG’s will play with DTS off when using MPEG Advance Xtra but they play VERY poorly. Unless you’ve got an exclusive audience with top of the line Intel Duos or Quads you can count on trouble. MIAW is the way to go. I’ve done two masked WMVs in the last month, one playing inside a circular saw blade, the other playing inside a mask shaped like a business card CD, they both work fine, even on entry level machines.
            • 3. Re: Layer Problem with Graphic over WMV
              andyulrika_is_back Level 1
              Thanks for all the replies.

              I'm a bit of a novice in Lingo and MIAWs. Can you tell me briefly how I can create a masked WMV.

              Thanks in advance.

              Andy
              • 4. Re: Layer Problem with Graphic over WMV
                Applied CD Level 1
                OK, I’m doing this by memory so I hope I haven’t left out any big steps. Also, the scripts could be cleaned up a bit but they do work.

                I’m going to assume you’ve got a Photoshop image of a TV and you want the video to play in the glass area of the image.

                1. Scale the TV image so that it can be used at 100% size in Director and save. Write down the height and width of the image in pixels, we’ll need them later.
                2. Use the path tool (or other method) to select the glass area of the TV, fill with 100% black
                3. Invert the selection and fill the background with 100% white
                4. Change the color mode to bitmap (50% threshold), use “save as” to change the file name to CRTmask and save as a 1 bit bmp
                5. Open a blank Director movie, make the stage size match the pixel dimensions of your original TV image
                6. Import your video and also drag the hold on frame behavior from the library into the cast
                7. Place the video into sprite 1, stretch to fill the stage if it doesn’t already; use the hold behavior to keep the playback head looping on the last video frame.
                8. Save this movie as videoPlayer.dir
                9. Open your original movie and import the TV image (with a color depth of 24bit) and the CRTmask with a color depth of 1 bit … Deselect the “trim white space” option when importing the mask … it will help with alignment.
                10. Place your TV image where ever you need it, place the CRTmask directly above it, set the background of the mask to transparent. Name the CRTmask sprite “videoProxy”
                11. Use the exit frame handler below in the first frame with the videoProxy sprite, this handler does most of the work defining the MIAW properties and moves the videoProxy sprite off stage. Put a hold on frame behavior at the end of the videoProxy sprite to keep your playback head looping while the video plays.

                global gOriginX
                global gOriginY
                global gWindowWidth
                global gWindowHight
                global gVideoWindow

                on exitFrame me
                myStageRect = _movie.stage.rect
                gOriginX = sprite("videoProxy").rect[1]
                gOriginY = sprite("videoProxy").rect[2]
                gWindowWidth = sprite("videoProxy").rect[3] - sprite("videoProxy").rect[1]
                gWindowHight = sprite("videoProxy").rect[4] - sprite("videoProxy").rect[2]
                myWindowRect = rect(myStageRect[1]+gOriginX,myStageRect[2]+gOriginY,myStageRect[1]+gOriginX+gWindowWidth ,myStageRect[2]+gOriginY+gWindowHight)
                gVideoWindow = window().new("videoWindow")
                gVideoWindow.fileName = "videoPlayer"
                gVideoWindow.type = #tool
                gVideoWindow.rect = myWindowRect
                gVideoWindow.resizable = FALSE
                gVideoWindow.titlebarOptions.visible = FALSE
                gVideoWindow.appearanceOptions.mask = member("CRTmask")
                gVideoWindow.open()
                sprite("videoProxy").loc = point(-1000,-1000)
                end

                OK, that’s enough to open your video and get it playing on the TV screen, controlling it is another matter. Here are some tips:

                1. At some point you’ll want the video window to go away. Use the following code snippet but be careful where you put it, make sure it can’t be called if gVideoWindow is void.
                if gVideoWindow <> 0 then
                gVideoWindow.forget()
                gVideoWindow = 0
                end if

                2. You can’t use the tempo channel to detect if the video has finished (not a good idea anyway). Fortunately, all of the normal lingo commands for video still work, you just need to reference the MIAW, for example, if you want to pause the video:
                gVideoWindow.movie.sprite(1).movieRate = 0
                to make it play again:
                gVideoWindow.movie.sprite(1).movieRate = 1
                to rewind:
                gVideoWindow.movie.sprite(1).movieTime = 0

                3. If your projector is not full screen the MIAW won’t necessarily follow the stage if the user moves the stage window. If this is the case you’ll need the following movie script. This script assumes the first frame where the video window is open is labeled "videoPlayer":

                global gOriginX
                global gOriginY
                global gWindowWidth
                global gWindowHight
                global gVideoWindow

                on moveWindow
                myLastFrameLabel = _movie.markerList[symbol(string(marker(0)))]
                if myLastFrameLabel = "videoPlayer" then
                myStageRect = _movie.stage.rect
                myWindowRect = rect(myStageRect[1]+gOriginX,myStageRect[2]+gOriginY,myStageRect[1]+gOriginX+gWindowWidth ,myStageRect[2]+gOriginY+gWindowHight)
                gVideoWindow.rect = myWindowRect
                end if
                end
                • 5. Re: Layer Problem with Graphic over WMV
                  andyulrika_is_back Level 1
                  Hi Applied CD

                  Thank you very much for the information and script. I got up to number 10 and ran my movie - the following error appeared

                  Script Error: Object Expected
                  gOriginX = sprite("videoProxy").rect[1]

                  Can you please help with this problem.

                  Regards

                  Andy
                  • 6. Re: Layer Problem with Graphic over WMV
                    Wolfgang Herold Level 2
                    Hi Andy, Applied CD gave the sprite a name ( "videoProxy").
                    So, name your sprite and it should work.
                    If your Director verison does not support naming sprites, use
                    the spritenumer for accessing the sprite. ( e.g. sprite(1).loc........)

                    Regards
                    Wolfgang
                    • 7. Re: Layer Problem with Graphic over WMV
                      Applied CD Level 1
                      Hi Andy,

                      Yes, Wolfgang is right, name the sprite (or refer to it by number) and it should work.

                      Also, after rereading my post I think things could be improved by setting gVideoWindow = 0 as soon as the projector starts, like in a startMovie handler or something. If you do this you can put the close video handler anywhere you like. Also, the on moveWindow handler could be streamlined a little as follows:

                      global gOriginX
                      global gOriginY
                      global gWindowWidth
                      global gWindowHight
                      global gVideoWindow

                      on moveWindow
                      if gVideoWindow <> 0 then
                      myStageRect = _movie.stage.rect
                      myWindowRect = rect(myStageRect[1]+gOriginX,myStageRect[2]+gOriginY,myStageRect[1]+gOriginX+gWindowWidth ,myStageRect[2]+gOriginY+gWindowHight)
                      gVideoWindow.rect = myWindowRect
                      end if
                      end

                      - Bob
                      • 8. Re: Layer Problem with Graphic over WMV
                        andyulrika_is_back Level 1
                        Thanks Wolfgang, that's what was missing.
                        • 9. Re: Layer Problem with Graphic over WMV
                          andyulrika_is_back Level 1
                          Hi Bob

                          I got the movie working but I seem to be back to square 1 since the wmv sits on top of my transparent TV mask. I know this because my original tv graphic had rounded corners and the WMV has square corners, you can see the WMV corners lying on top of the rounded TV mask, that's how I know.

                          Have I missed something or did you intend it to be like that. By the way, thanks for the extra code.

                          Help much appreciated.

                          Regards

                          Andy
                          • 10. Re: Layer Problem with Graphic over WMV
                            Applied CD Level 1
                            The WMV window should sit on top of the TV graphic (which will be just a normal graphic, no transparency required), however, a mask is being applied to the WMV window which should round the corners of the window into the shape of the TV glass.

                            If your WMV window (call videoPlayer) still has square edges check the following:

                            Make sure the stage cast has a 1 bit image member called CRTmask. The black portion of this image should be the shape of the TV glass.
                            Make sure the following line is correct, this is the line that applies a mask to the window: gVideoWindow.appearanceOptions.mask = member("CRTmask")

                            If you’re still having problems try temporarily replacing the WMV in videoPlayer.dir with a still graphic. Go back to your main movie and check if the graphic is properly masked.

                            BTW: I should have asked this before, are you using MX04? MM made major changes to MIAWs between MX and MX04. I think you can still mask windows in MX but the syntax could be very different.
                            • 11. Re: Layer Problem with Graphic over WMV
                              andyulrika_is_back Level 1
                              Hi Bob

                              I eventually got it working, thanks for all your help. The name was missing! I didn't realise you had to publish the movie to actually see what it looks like without the pop-up window style windows box. I'm going to now check your other code for exiting the MIAW when I leave the frame... Should I use

                              on exitframe me
                              if gVideoWindow <> 0 then
                              gVideoWindow.forget()
                              gVideoWindow = 0
                              end if
                              end

                              To close the window on exiting the frame?

                              By the way, I'm using Director mx 2004.

                              Also, just wondered if you had any tips on improving the look of my 1 bit TV screen. I used a lot of grey shading on the original and it looks like sh*t. I suspect it will have to be very simple.

                              Many thanks.

                              Andy

                              • 12. Re: Layer Problem with Graphic over WMV
                                Applied CD Level 1
                                Sorry for the delay. Yes, you could use an exit frame handler to get rid of the video window, it all depends on how you leave the video frame. I usually have navigation buttons along with the video so in my case I more often close the MIAW with mouseUp handlers on the buttons that take the user away from the video.

                                As for your TV screen you’re right, using gray shading in the mask won’t work, the video either shows through the mask (where it’s 100% black) or it doesn’t (where it’s white), unlike an alpha channel there’s no blending between the video and the background graphic. You should have a good idea about the quality of your mask in Photoshop when you change the color mode to bitmap (not the same as saving as a BMP), all of the grayscale information will be abandoned at that time. If the edges are rough or if there are pin-***** spots of white in the glass area then your method for selecting the glass could be improved. Using the magic wand to select an area is convenient but not terribly precise, I generally prefer to use the path tool to draw a path around the area to be selected, turn the path into a selection, then fill with black. Invert the selection, then fill with white. Change the color mode to bitmap and save. You might have some stair-stepping where a smoothly curved edge would be preferred but generally it has never been bad enough to be objectionable.

                                PS: It occurred to me that you might be trying to simulate the glare and shape distortion seen on antique television sets from the 40’s and 50’s. If that’s the case it’s gonna be tough, the MIAW is always going to look a little too flat using this technique.
                                • 13. Re: Layer Problem with Graphic over WMV
                                  andyulrika_is_back Level 1
                                  Hi Bob

                                  Thanks again for your input. I'll try a little experimenting with Bitmaps but will probably less adventurous in my design. However, I'm grateful for your help.

                                  All movies are working nicely now.

                                  Kind regards

                                  Andy