21 Replies Latest reply on Dec 12, 2007 11:59 PM by Rahul Kathet

    Save movie  Clip in frame as jpeg

    hanyegypt Level 1
      We Are Developing A web Application as the following :
      the Client Can select A template then Write words on over it and Save the Template as Jpeg format ,we did the first part ,how we can save the movie Clip as JPEG format ,I looked in the Bitmap class and i did not found any Solution,also I used the PHP to send Data to It From Flash but it is very Slow Proccess is there any way to do this from Flash


        • 1. Re: Save movie  Clip in frame as jpeg
          kglad Adobe Community Professional & MVP
          check mario klingemann's bitmapexporter class.
          • 2. Re: Save movie  Clip in frame as jpeg
            hanyegypt Level 1
            Thank you Very match for your answer ,but I wander can Flash export the JPEG alone without Any Server Side Languge (PHP,ASP) thanks Again
            • 3. Save movie  Clip in frame as jpeg
              Greg Dove Level 4
              You can't export the jpeg alone from flash if flash is running in the browser. It must go via the server in order to be saved locally. You say you're developing a web app... so I assume that's where its running.
              If you want to speed things up then you will need to use as3 where you can use a JPEGencoder class which creates a ByteArray that represents the jpeg that you can send as a binary data. That means the round trip to the server and back to the local machine to save the jpeg locally is quicker, because the data being sent both ways is smaller and as an extra bonus the server also doesn't need to do any processing to convert it to jpeg format.
              • 4. Re: Save movie  Clip in frame as jpeg
                hanyegypt Level 1
                I'm very happy with your help floks thank you again
                I downloaded klingemann's bitmapexporter class the Example Work with Web Cam how can I make it Load image
                • 5. Re: Save movie  Clip in frame as jpeg
                  kglad Adobe Community Professional & MVP
                  it works with any bitmapdata object: create a bitmapdata object, use the draw() method to copy the data from your movieclip to the bitmapdata object. then use the bitmapexporter class to upload your image to your server.
                  • 6. Re: Save movie  Clip in frame as jpeg
                    hanyegypt Level 1
                    http://www.7everyweek.com/BitmapExporterDemo2.html

                    Please See the above link I just use the example to load Image width=500 height=400 as you try to save the Image
                    very Slow Proccess
                    Please Adive Me what to do to make it more Fast
                    • 7. Re: Save movie  Clip in frame as jpeg
                      kglad Adobe Community Professional & MVP
                      you're doing something wrong.
                      • 8. Re: Save movie  Clip in frame as jpeg
                        hanyegypt Level 1
                        this my Code i olny load image in a movieClip and I changed the width and height of the movie
                        myimage= movieClip

                        /////////
                        import flash.display.BitmapData;
                        import com.quasimondo.display.BitmapExporter;

                        myimage.loadMovie("1.jpg") ;

                        var snapshot:BitmapData = new BitmapData(500,400,false);

                        // You will have to change the gatewayURL to your server
                        // except if you are testing this locally:
                        BitmapExporter.gatewayURL = " http://www.7everyweek.com/BitmapExporter.php";

                        // It is a good idea to listen to the various events that
                        // BitmapExporter provides:
                        BitmapExporter.addEventListener( "progress", this);
                        BitmapExporter.addEventListener( "status", this);
                        BitmapExporter.addEventListener( "error", this);
                        //BitmapExporter.addEventListener( "complete", this);

                        function save():Void
                        {
                        // Check if there is still an export going on:
                        if (BitmapExporter.getStatus() == "idle") {

                        // update the bitmap with the latest camera image:
                        snapshot.draw(myimage);

                        progress_back._visible = progressbar._visible=true;

                        // this is only to compare the different speeds
                        timer = getTimer();
                        onEnterFrame = updateTimer;

                        // Since the webcam image is very small we can get away with turboscan here:
                        BitmapExporter.saveBitmap(snapshot, "testsnapshot.jpg", "turboscan", 0 );

                        // Usually it is receommended to use one of the other modes:
                        // BitmapExporter.saveBitmap(snapshot, "snapshot.jpg", "fastscan", 0, 70);
                        // BitmapExporter.saveBitmap(snapshot, "snapshot.jpg", "default", 0, 70);
                        // BitmapExporter.saveBitmap(snapshot, "snapshot.jpg", "palette", 0, 70);
                        // BitmapExporter.saveBitmap(snapshot, "snapshot.jpg", "rgb_rle", 0, 70);

                        }
                        }

                        function updateTimer(){
                        time.text = getTimer() - timer;
                        }



                        function progress(evt:Object):Void {
                        progressbar.setProgress(evt.current, evt.total);
                        progressbar.label = evt.message+" (%3%%)";
                        }

                        function error(evt:Object):Void {
                        errormsg.text += evt.message+"\n";
                        delete onEnterFrame;
                        trace( evt.message )
                        }

                        function status(evt:Object):Void {
                        trace( evt.status );

                        switch (evt.status) {

                        case "contacting server" :
                        save_btn._visible = false;
                        save_btn.enabled = false;
                        cancel_btn._visible = true;
                        cancel_btn.enabled = true;
                        break;

                        case "idle" :
                        progress_back._visible = progressbar._visible=false;
                        save_btn.enabled = true;
                        save_btn._visible = true;
                        //cancel_btn.enabled = false;
                        cancel_btn._visible = false;
                        onEnterFrame = null;
                        break;

                        case "retrieving":
                        onEnterFrame = null;
                        break;
                        }
                        }



                        save_btn.onPress = function() {
                        this._parent.save();
                        };


                        progress_back._visible = progressbar._visible=false;
                        //cancel_btn._visible = false;
                        //save_btn._visible = true;
                        progressbar.minimum = 0;
                        //cancel_btn.enabled = false;
                        var timer:Number
                        var errormsg:TextField;
                        ////////////////
                        • 9. Re: Save movie  Clip in frame as jpeg
                          Greg Dove Level 4
                          My guess is that it relates to this comment line
                          // Usually it is receommended to use one of the other modes:
                          • 10. Re: Save movie  Clip in frame as jpeg
                            kglad Adobe Community Professional & MVP
                            the mode is ok. hou probably have a security problem.

                            what domain is your flash on and if it's different from 7everyweek.com, do you have a cross-domain security policy in place? if it's the same domain, use a relative path to the php file.
                            • 11. Re: Save movie  Clip in frame as jpeg
                              Greg Dove Level 4
                              kglad: I've never used that class, so I don't really know what's happening but I was getting script timeout during 'analyzing bitmap' before... I thought it might have been because of the size of the image versus the encoding approach. But I'm not getting the timeout now. Its definitely not a x-domain issue.
                              I'm not sure exactly what it is but the script uploads the encoded image which is 2034283 bytes of data.
                              The server gives a 500 Internal error with that. It might be too big for some setting on the server.
                              • 12. Re: Save movie  Clip in frame as jpeg
                                kglad Adobe Community Professional & MVP
                                it's only 500x400. i've used slower scans on larger images without a timeout issue.

                                how do you know it's not a cross-domain issue?
                                • 13. Save movie  Clip in frame as jpeg
                                  Greg Dove Level 4
                                  I checked what was happening in fiddler. You can always find cross-domain issues by observing whether flash attempts to load a policy file (and fails). It doesn't try here. And it calls the script 3 times, each time the server responds. But with the encoded image it returns a 500 code "internal error". The reason I thought it might be the encoding method is that the size of the encoded data is huge. Approach 2 meg. I assumed that the 'web-cam' approach would favour execution speed over compression because of the comments in the code.

                                  To clarify: I had the timeout error on a previous attempt - I don't get it now. (Perhaps I had too much other stuff using my CPU at the same time on the previous attempt or the OP changed the code since)
                                  • 14. Re: Save movie  Clip in frame as jpeg
                                    Greg Dove Level 4
                                    kglad: You can also observe the requests happening in firebug as well. Its normally quicker and easier than fiddler, but less info.
                                    • 15. Re: Save movie  Clip in frame as jpeg
                                      hanyegypt Level 1
                                      Thank you All for your Comments,you are greate guys
                                      I tried the JPEGencoder in the AS3 and it works fine and capture Movie from video player and save it into the server
                                      can I use it to capture A frame in the time line or a movie clip
                                      thanks again
                                      • 16. Re: Save movie  Clip in frame as jpeg
                                        Greg Dove Level 4
                                        Its the same process with the JPEGEncoder class.
                                        If you have the upload part already working in your example then you just need to use your JPEGEncoder instance to encode the bitmapData (which generates the ByteArray representing your jpeg). Use that in the same code that sends the movie frame capture to your server now...

                                        As a side comment, you probably should have mentioned whether you were able to use as3 at the start. I did mention it earlier and recommended it as a better option (the BitmapExporter class seems like landmark code for as2, but what you're doing is much easier in as3). Mentioning this earlier would have saved kglad's and my time trying to fix your as2 related problem. This is not an angry comment :-) ... just a friendly suggestion for the future.

                                        • 17. Re: Save movie  Clip in frame as jpeg
                                          kglad Adobe Community Professional & MVP
                                          i didn't know that. thanks gwd.
                                          • 18. Re: Save movie  Clip in frame as jpeg
                                            Greg Dove Level 4
                                            kglad: no problems. I've done a lot of http debugging for myself recently and started to notice things like that. It's "impressive" (lol) when you can tell someone exactly what they need to do just from looking at their test site and observing the failed policy file loads. The one issue that seems the most common -if you deal with it here or anywhere else- is with people having www.mysite.com and mysite.com work for the same site - you can see the swf in one subdomain looking for the policy file at the other one and not finding it (because they wouldn't think they would need one) even though its the same 'site'. It might be because maybe they've hard coded the LoadVars.load etc. In that case the safest option is to tell them to put a policy file that grants both of their own addresses access.
                                            • 19. Re: Save movie  Clip in frame as jpeg
                                              hanyegypt Level 1
                                              Actuly I do not no any ac3 Code, I olny edit the Example to upload in my server
                                              and It work fine ,I will need to Study AS3 to use this Class
                                              if there is any simple steps to do so i can use this Class
                                              thanks again
                                              • 20. Re: Save movie  Clip in frame as jpeg
                                                Rahul Kathet Level 1
                                                hi
                                                my name is rahul, i was working in flash roomplanner i had completed the designing part some but i want to know that what i have to do net i have to make it like admin can change any thing like if he want to change the bed image then he could change from his admin part and it should update in server, is i can do using xml file like if client is updating some images then that xml should update, there are two languages are using one is flash action script and another is ASP.NET, in .NET admin part will work and in flash user can see, but how can i attached xml and rewrite XML file, i cant understand you see this link as a example " http://flash.360house.com/sp/rplanner.cfml?customer=255301" how can i use xml and which script i have to put in flash to load xml data using id or how can i rewrite xml from flash only.

                                                thanks
                                                Rahul Kathet
                                                • 21. Re: Save movie  Clip in frame as jpeg
                                                  Rahul Kathet Level 1
                                                  hi
                                                  my name is rahul, i was working in flash roomplanner i had completed the designing part some but i want to know that what i have to do net i have to make it like admin can change any thing like if he want to change the bed image then he could change from his admin part and it should update in server, is i can do using xml file like if client is updating some images then that xml should update, there are two languages are using one is flash action script and another is ASP.NET, in .NET admin part will work and in flash user can see, but how can i attached xml and rewrite XML file, i cant understand you see this link as a example " http://flash.360house.com/sp/rplanner.cfml?customer=255301" how can i use xml and which script i have to put in flash to load xml data using id or how can i rewrite xml from flash only.

                                                  thanks
                                                  Rahul Kathet