AMFPHP Live JPEG Encoder 0.4

Now that AMFPHP 1.9 supports ByteArray transfer, I updated the "Live JPEG Encoder" so that it uses Flash Remoting technology with AMFPHP and FileReference.

We now have a 0.4 version which gives better performance and simpler code. JPEG encoding class has been also updated concerning the "Duplicate variable definition" warnings.

New version in action here

Update 05/07/05 :
WebCam version available here

Update 03/09/09 :
Sources have been updated to handle Flash Player 10 security restriction concerning the method.

Download sources : Live JPEG Encoder 0.4 Sources

Comments (121)

  1. guojian wrote:

    Very nice, would you be able to point me to a good source to get code for JPEG decoder? I want to try to port that to flash just for fun. thanks.

    Friday, April 27, 2007 at 7:47 pm #
  2. Thibault Imbert wrote:

    hi guojian,

    You mean you are looking for a JPEG decoder ? Can you tell me more ?

    cheers ;)

    Sunday, April 29, 2007 at 5:43 pm #
  3. guojian wrote:

    I playing with saving different data and graphics in one single xml file… the idea is to avoid having to keep track of all the different assets.

    anyway, right now I added a the ability to create a snapshot with a webcam and then allow the user to draw on it. I am currently just doing a Base64 and it is quite large. I know a jpeg decoder will be slow (especially in AS2) but speed is not that important.

    Monday, April 30, 2007 at 5:47 am #
  4. Frans wrote:

    Hi Thibault,
    I must say you did an excellent job with this. It’s so fast !!
    I have been playing with older versions of snapshot alike applications to grab pictures from a live webcam, bmp->jpg in php and have it saved on the server. The idea behind it was to give members on our hobbysite (just a little fun community) the opportunity to take a live webcamshot, have it saved on the server and returning an image bbcode to use in posts, private messages etc. This works, but is a lot slower than your soulution. Would it be possible for you to rewrite your application so it can be used with a webcam? Please contact me, i am willing to donate for this.

    Saturday, May 5, 2007 at 12:31 pm #
  5. Thibault Imbert wrote:

    hi Frans,

    Tks for your comment, I did a webcam version for you, you can try it here :

    Download the sources again, the zip now includes another fla called media_snapshot_webcam.fla

    cheers ;)

    Monday, May 7, 2007 at 3:17 am #
  6. Kuzco wrote:

    i was trying to install the web service on my server.
    when i call gateway.php from the browser all looks fine, but when i just change your server in the code to my server, the flash gets stuck on “Please wait…”
    does anyone have an idea? did i need to do something else in the server besided upload the amfphp folder?
    (also gave write permission to the folder)

    thanks and cheers!

    Wednesday, May 9, 2007 at 6:11 pm #
  7. Thibault Imbert wrote:

    Hi Kuzco,

    did u try reaching the gateway.php page on your server with your browser ?


    Friday, May 11, 2007 at 11:48 am #
  8. Isak wrote:

    Could the bytearrays compress method help in the time it takes to send it to the server? If so do you need to uncompress it serverside?

    Wednesday, May 16, 2007 at 1:42 pm #
  9. Frans wrote:

    Hi Thibault,

    I am sorry for my late reaction, I didnt know you posted it here, was looking forward to an email lol.. and hoping to contact you directly.

    I was just trying your webcam version, but for some reason my cam (logitech pro 5000) stays black, it doesnt even turn on (no led light) with your script, so I wasnt able to test it :( ) I will download the files though and have a play with it, to see if i can find what’s wrong lol. Thank you very much for this effort already :) Frans

    Thursday, May 31, 2007 at 12:21 pm #
  10. Salvador wrote:

    webcam version doesn’t work
    well maybe it works, but it doesn’t show webcam!
    i hope you could fix this, because this is tooooo interesting ;)

    Saturday, June 2, 2007 at 10:29 pm #
  11. Thibault Imbert wrote:

    Hi Salvador,

    I tried it and it works, have you tried it in CS3 or on a web page ?


    Sunday, June 3, 2007 at 11:06 pm #
  12. Salvador wrote:

    I tried both! Here in the webpage and downloading the files and opening them in Flash CS3. Nothing of this works :( As Fran says… it asks me to let access to my webcam, but when I accept it doesn’t show it, and the led is off

    Monday, June 4, 2007 at 1:22 am #
  13. Salvador wrote:

    I tried it in Windows and it worked. Oh too bad I wont design only for Windows :O
    Any clue about how to fix it? Im on a Macbook. It worked in Windows with Parallels using the iSight, but it doesn’t work on Mac OSX. Thank you.
    If you are able to, can you check the url in my name and tell me if you see a AS3 version of my project easy to port? Thank you very much, this is so important to me! I’m design student and this is my project

    Monday, June 4, 2007 at 1:30 am #
  14. Seb wrote:

    Salut Thibault,
    J’ai quelques problème pour commencer avec le script. Je commence ma transition vers AS3 donc il est probable que quelques settings m’échape. Ici ( tu peux voir les erreurs générées.
    As-tu une idée de ce que j’ai mal fait? Pour le moment j’ai simplement décompressé le zip sans toucher la structure des dossier.

    Wednesday, June 6, 2007 at 6:21 pm #
  15. Thibault Imbert wrote:

    salut Seb,

    est tu sur de ne pas compiler en AS2 ?
    peux tu vérifier que tu compiles bien en AS3 ?

    merci !

    Thursday, June 7, 2007 at 9:05 am #
  16. god wrote:

    thanks bitch.
    now my work is easier. for harder, so I can implement this into my projects.

    Friday, June 8, 2007 at 10:03 am #
  17. Seb wrote:

    Merci Thibault!!
    Ca fonctionne à merveille. Effectivement je compilais en AS2.
    Encore bravo pour ce très beau travail…

    Monday, June 11, 2007 at 10:45 pm #
  18. Jo wrote:

    Salut Thibault!

    Very nice App you created. I’m very excited and tried to upload this on my server for some tests. Unzipped, uploaded and changed Paths in AS/exported Flash9-AS3.

    It doesn’t work and after reading you comments i loaded the AMFPHP-Browser.
    This is the result:

    errorID = 0
    faultCode = “Client.Error.MessageSend”
    faultDetail = “Channel.Connect.Failed error NetConnection.Call.BadVersion: ”
    faultString = “Send failed”
    message = “faultCode:Client.Error.MessageSend faultString:’Send failed’ faultDetail:’Channel.Connect.Failed error NetConnection.Call.BadVersion: ‘”
    name = “Error”
    rootCause = (Object)#1
    code = “NetConnection.Call.BadVersion”
    description = “”
    details = “”
    level = “error”

    I’m always trying to get things done by myself, but google search didn’t help. Can you give me a hint want to do?

    Thanks in advance,

    Tuesday, June 12, 2007 at 4:41 am #
  19. Jo wrote:

    Forget the server-config:
    php5, reg. globals off (is that the problem?)

    Tuesday, June 12, 2007 at 4:53 am #
  20. Hugh wrote:


    I took a quick look at why there are people unable to see their webcam in the webcam version. You’ve specified Camera.getCamera(0); however, for someone like me, my webcam isn’t at 0. I took out the 0 and it worked fine.

    Friday, June 15, 2007 at 2:16 pm #
  21. can't make it work wrote:

    Hi Thibault, it looks good, but i can’t make it work, i’m trying to do an educational tool so kid in my class can draw and then print or mail the drawing, i download the, but no good results, thanks and best regards.

    Monday, June 18, 2007 at 2:39 am #
  22. Thibault Imbert wrote:


    what is not working ?

    can I have a look, so that I can help you ?

    regards ;)

    Monday, June 18, 2007 at 9:07 am #
  23. tim wrote:

    Hi Thibault, I’m just trying to play around with this. Everythings going great except I can’t change where the snapshot image is loaded to (total noob). Can you point me in the right direction?

    Much appreciated in advance


    Tuesday, June 19, 2007 at 2:49 pm #
  24. Thibault Imbert wrote:

    Hi tim,

    you are talking about where the snapshot is saved ?


    Thursday, June 21, 2007 at 9:37 am #
  25. Call.BadVersion wrote:

    Hi, very nich app. I am trying to run it on my server and I have every time NetConnection.Call.BadVersion -> Error #2044: NetStatusEvent unverarbeitet. level=error, code=NetConnection.Call.BadVersion
    at media_snapshot_fla::MainTimeline/media_snaps
    It points to NetConnection and then I thing from the log_file from php is something like start_session() from the Filters.php. Do you have any idea why it does not work?

    Thursday, June 21, 2007 at 6:20 pm #
  26. tester wrote:

    Is it possible to increase image size? Simply increasing webcam video size does not make final capture larger or more detailed. Maybe an array limitation?

    Friday, July 13, 2007 at 8:38 am #
  27. ryan wrote:

    I too am running into the NetConnection.Call.BadVersion error. I tried just going to and it said that I have a Internal Server Error. I am thinking that I am just over looking something dumb here, but I am not sure what it is. Any help would be fantastic. Thanks in advance!


    Monday, July 16, 2007 at 2:37 am #
  28. Thibault Imbert wrote:

    hi tester,

    you want to increase the webcam snapshot size, right ?

    hi ryan,

    when you try to access the page, it sas that you have an internal server error ? can you paste it here ?


    Monday, July 16, 2007 at 8:02 am #
  29. ryan wrote:

    Hi Thibault,

    Thank you for your quick return. I figured out what was going on. the .htaccess file was the cause. Once I got rid of it everything worked great!

    Thanks again for your work and contributions to the flash community!

    Monday, July 16, 2007 at 9:15 am #
  30. tester wrote:

    hi thibault,

    yes, I tried increasing the webcam input video dimension in the script, but that didn’t change the final output, mainly I want to know if it is possible to save a larger jpg [higher quality] and which files need their vars changed to accomplish that


    Tuesday, July 17, 2007 at 10:57 am #
  31. My hosting company has remove php hosting from my site where I have a Flash remoting project. I need to get this to work in ASP. Do you have any idea of the code to replace the create.php doc with a create.asp doc?

    I’ve been working on this for a few weeks and can’t get it. I would be willing to pay you for your efforts.



    Tuesday, July 24, 2007 at 3:40 pm #
  32. deen wrote:

    hi, i downloaded the source, put on my server, set chmod 777 for “pictures” folder and it doesnt work.. it says “please wait” when “Capture and Save” is pressed..
    i can reach the gateway.php and it says “amfphp and this gateway are installed correctly”.. could someone help ? thanks

    Thursday, August 2, 2007 at 7:59 pm #
  33. Thibault Imbert wrote:

    Hi deen,

    If you reach the browser directory with your browser can you call the remote method ?

    any error messages ?

    let me know ;)

    Thursday, August 2, 2007 at 8:15 pm #
  34. deen wrote:

    i got this error
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’fopen(../../../pictures/capture.jpg): failed to open stream: No such file or directory’ faultDetail:’/u/guests/usr/deen/htdocs/jpeg/amfphp/core/shared/util/CompatPhp4.php on line 28′”
    thanks for helping

    Thursday, August 2, 2007 at 8:29 pm #
  35. Thibault Imbert wrote:

    Hi deen,

    Your folder may not be accessible from the remote service, check its location and make sure the remote service can write to it.

    Thursday, August 2, 2007 at 9:18 pm #
  36. deen wrote:

    thank you. i´ve solved it right now. For those having the same problem: My “pictures” folder was in amfphp folder, but has to be in root of this aplication.
    thank you for this great code (o:

    Thursday, August 2, 2007 at 9:43 pm #
  37. Thibault Imbert wrote:

    Happy it works deen ;)

    Thursday, August 2, 2007 at 9:59 pm #
  38. tester wrote:

    Still testing your great applet. Self-encoded flv videos do work.

    Flv videos taken from youtube [stored locally] don’t seem to work, they play but cannot be taken a preview of, nor be saved.

    What might cause this: encoding, protection, settings, … ?

    ArgumentError: Error #2015: Invalid BitmapData.
    at flash.display::BitmapData$iinit()
    at media_snapshot_fla::MainTimeline/onPreviewClick()

    Friday, August 3, 2007 at 11:00 am #
  39. 438 wrote:

    Thanks for your project!
    I can save the files to my server’s folder. but,
    how can I save the jpg files to DB (like mySQL’s table)
    I wanna make some gallery board with livecam photo. could you advice me plz?

    Monday, August 6, 2007 at 4:16 pm #
  40. Thibault Imbert wrote:

    Hi 438,

    You can save the images in your mySQL database with a blob field. You’ll be able to store the binary stream and then retrieve it, to display it.

    let me know, :)


    Tuesday, August 7, 2007 at 12:06 am #
  41. tester wrote:

    FYI regarding problem as described above:
    some flv’s work, some don’t

    problem: meta data missing
    solution: injecting meta data

    I used

    Friday, August 10, 2007 at 10:20 am #
  42. Andrei wrote:

    Hi Thibault,
    Very nice work !!
    I was wondering: is it possible to do the same thing with flv s and mp3 s (ie. send/receive flv files from php to flash ) ?
    Thanks a lot

    Friday, August 10, 2007 at 4:59 pm #
  43. 438 wrote:

    I’ve maded save the IMG to DB. now I can see that in my imageboard .

    anyway I have a Question before I made that.
    How can I increase cam IMG resolution?
    I use macbook now, but in FLASH the cam img shows low resolution much more then PHOTOBOOTH.

    How can I do that?

    Saturday, August 11, 2007 at 4:36 pm #
  44. naqk wrote:

    I downloaded your source but can not use .fla file. Please re-check this Zip source or send to me via email.

    Thanks a lot.

    Wednesday, August 22, 2007 at 6:49 pm #
  45. Carey wrote:


    I’ve been working for two months trying to get this to work with or coldfusion. Do you have any experience with either one and how we could make your application work with either or. I don’t have php on my server.

    Monday, September 10, 2007 at 3:20 am #
  46. Carey wrote:

    Also, none of the links are working currently…

    Monday, September 10, 2007 at 3:21 am #
  47. Thibault Imbert wrote:

    Hi Carey,

    Please check again, I have updated everything. the server has been hacked a few days ago, I lost everything so it takes a little time to get everything back ;)

    Concerning your problem with can you send me a little mail so that we can talk about it :)


    Monday, September 10, 2007 at 4:22 am #
  48. david ee09 wrote:

    Bonjour Thiebault

    Je voulais juste te signaler un problème sur ton zip. Le dossier “pictures” doit être placé au même niveau que le dossier amfphp et non pas dedans…sans quoi on a le problème décrit par Kuzco.

    En tout cas pour moi c’est comme ça.

    merci beaucoup, ton truc est terrible.

    ps: désolé pour le français, mais j’ai vraiment du mal à m’exprimer correctement en anglais.

    Saturday, September 15, 2007 at 10:46 pm #
  49. Marco wrote:

    Hi Thibault,

    there’s something i don’t understand. In your php class you write that the bytearray is in the data property of your jpegstream but when i send to php the encoded bytearray, i get no data property on it…

    var vJPEGEncoder:JPEGEncoder = new JPEGEncoder(70);
    var vSortie:ByteArray = vJPEGEncoder.encode(aBitmapData);
    var vStreamObject = {jpegstream:vSortie}; (“JPEGEncoder.saveToServer”, this._responder, vStreamObject);

    ça me dépasse…

    Tuesday, September 18, 2007 at 5:49 pm #
  50. Thibault Imbert wrote:

    Hello david ee09,

    Thanks, I have updated the sources ;)

    Tuesday, September 18, 2007 at 6:47 pm #
  51. Yuri wrote:

    Hi Thibault
    I’ve been playing around with your encoder, and looks like I got it 50% working.
    Only problem now, is that I get “0″ (zero) as a result from my query…no error messages. I set the folder permissions on my server, but it’s still doing it.
    Can you give me any indication on what you think the problem might be?

    Tuesday, September 18, 2007 at 7:18 pm #
  52. Thibault Imbert wrote:

    Hi Yuri,

    There was a problem in the sources you may have downloaded, I just updated the sources a few minutes ago. Make sure that the pictures folder is at the same level as the amfphp folder.

    let me know :)

    Tuesday, September 18, 2007 at 7:20 pm #
  53. Yuri wrote:

    Thanks for the quick reply!
    Ok…I changed the source, and made sure the ‘pictures’ folder is at the right level.
    Here it is on our server, so you can see what it’s doing:

    After saving it to server, a file ‘capture.jpg’ is created in the ‘pictures’ folder (URL:
    but it’s empty and at 0kb
    My net debugging proxy still shows that the service is returning a “0″(zero).
    I’m sure I must be doing something wrong…

    Wednesday, September 19, 2007 at 5:50 am #
  54. Yuri wrote:

    Hi Thibault
    The links I posted won’t work anymore as I took it off our server.
    I managed to do a workaround in Flash based on the Flex example from Alessandro Crugnola.

    Anyways, thanks for your help!

    Friday, September 21, 2007 at 2:18 pm #
  55. Marco wrote:

    Salut Thibault,

    je n’arrive toujours pas à comprendre pourquoi et comment les données de l’image se trouvent dans $bytearray->data du côté php. Y a t il une transformation des données transmises quelque part ? Merci et encore bravo pour le boulot

    Monday, September 24, 2007 at 1:42 pm #
  56. Daniel wrote:

    Ok guys and gals, I love this project. Right up my alley. Problem is I’m working in WOOT! heh. I’ve been racking my brain about how to simply save an image from a flex 2 canvas to my server HD using (capture ui component, encode to PNG, and remote it to I can save the file once it’s in; I have done so with xml files just fine. my problem is getting the image captured from the canvas, and remoted to an page. You know, sending a bytearray from flex2 to an handler. At this point even just saving an all out bitmap to the server HD via would be fine. Some code, or just some links to reference would be great. I don’t know why I have been hung up on this soo long. It seems like it should be a pretty easy process. Capture uiComponent, urlRequest my page, receive byteArray with the page, save to HD with the page. Any help would be greatly appreciated, and I think if anyone could help it would definitely be yous guys. ;)

    Thank you either way,

    PS sorry I’m gabbing about on here.

    Tuesday, October 9, 2007 at 8:49 am #
  57. Thibault Imbert wrote:

    Hi Daniel,

    You can send the ByteArray through the post buffer and then retrieve it in ASP.NET with the following script :

    // retrieve a bytearray from the post buffer
    byte[] myBuffer = Request.BinaryRead(Convert.ToInt32(Request.InputStream.Length));
    // create file handler
    // write the bytes
    File.WriteAllBytes(@”D:\Dev\test.pdf”, myBuffer);

    let me know ;)


    Tuesday, October 9, 2007 at 9:43 am #
  58. ValdeX wrote:

    Hi Thibault, great app!!!

    First sorry for my english and my little knowledge of Flash. I made just for fun a very simple flash app where you can build a custom guitar loading external SWF’s with the selected options. I always wanted to make a button that can save a JPG of the upper side of the app (like a partial screenshot) on the user hard disk or better if the app can upload it automatically to a free image host. I’m a noob in Flash/PHP or whatever so I don’t have a clue of how can I do that. Can you help me?

    This is the app:

    Sorry for boring you :(

    Thursday, October 11, 2007 at 7:59 am #
  59. deej wrote:

    hey Thibault, real handy script man… but m stuck with a little problem. is it possible to pass on a movie clip to jpegencoder with its registration point at the centre. (-movieclip.width/2, -movieclip.height/2) … currently with this registration point its rendering only bottom right quarter of the image. i tried changing some settings on the but no success. would be great if you could reply soon… m workin on a multitouch app so have to keep the registration points at the centre to allow scalin and rotation

    Saturday, October 20, 2007 at 5:37 am #
  60. Daniel wrote:

    Hello, sir. Wonderful app! I’ve altered it a bit to save whatever’s on the stage in a certain area, and that works great. The only problem is that any text that gets saved (viewed in preview window) is aliased. Is there some way to save anti-aliased text as a jpeg with this? Thanks much!

    Sunday, October 21, 2007 at 11:19 pm #
  61. Yuri wrote:

    I just finished a tutorial based on the same concept. Sending a JPG encoded container as a ByteArray to server-side. I’ve also included MIME email sending.
    Feel free to have a look. More details at www[dot]theliblab-tutorials[dot]com

    any comments appreciated ;)

    Wednesday, October 24, 2007 at 12:41 pm #
  62. Kelly wrote:

    Hi Thibault,
    This is incredible, and it works so well. I was just told that this was impossible by another Developer.
    Anyway, the only problem I am having is capturing multiple images(only saves one image)…seems like when I save the new one, I can’t name it anything but “capture” and it just replaces the old file.
    Any ideas?
    Thank you for your great work!

    Wednesday, November 7, 2007 at 12:14 am #
  63. Phil wrote:

    Thibault, thank you kindly for making this tool and sharing with us! I notice that the PHP files in the .zip are licensed under the GPL, and I don’t see any license mentioned in the actionscript. Would you mind telling me a little bit about what our use rights would be?

    I work for a small studio; we are interested in using this in a web app which is destined for a non-profit site devoted to improving quality of life for cancer survivors. Our studio won’t really be making any money off the work, but I don’t think our clients would want to have the program be open-sourced under the GPL.


    Thursday, November 8, 2007 at 5:06 am #
  64. Thibault Imbert wrote:

    Hello Phil,

    You can use the ActionScript for whatever you want, my pleasure to help you :)

    AMFPHP is an open-source project which lets you use it freely and commercially.

    kind regards,


    Thursday, November 8, 2007 at 10:27 pm #
  65. Phil wrote:

    Thank you so much!


    Tuesday, November 13, 2007 at 1:50 am #
  66. Mark wrote:

    This is a very nice script. I was wondering how can I increase the quality of the webcam images. The images are quite low even if the slider is set to 100. Any help would be appreciated.

    Wednesday, November 14, 2007 at 8:19 pm #
  67. Juan Matijas wrote:

    Thank you very much for this script! Now, as Kelly posted earlier, the possibility of saving multiple files is not working; even though the flash sends the new Date().getTime()name, this is not accomplished in the PHP script, since it is writing the new image over the last “capture.jpg”. Is there any way that we can pass this unique name to the service?

    Tuesday, November 20, 2007 at 8:26 pm #
  68. Tin Aung Latt wrote:

    Hi Thibault,

    Is there any way to recomplie the source file with flex builer 2? If so, how can I supppose to open the source file that there is no mxml file. If there is any way to open with flex builder 2, please guide me through…

    Thanks again

    Wednesday, November 21, 2007 at 5:57 am #
  69. Arnaud wrote:

    J’ai posté un message hier mais je ne le retrouve pas
    quelqu’un peut me dire où est il ?

    Wednesday, November 21, 2007 at 11:02 am #
  70. Arnaud wrote:

    J’ai installé jpeg encoder sur mon poste xp avec apache/mysql/php4.2.0
    Quand je lance gateway.php, j’ai la page qui dit que c’est ok
    Quand je lance le broser, j’ai bien amfphp et jpegencoder mais après je ne vois pas quoi faire pour trouver le fichierr test ratatouille-tsr1_h480p1.flv
    merci de votre aide

    Wednesday, November 21, 2007 at 11:11 am #
  71. Carey wrote:

    I can’t seem to contact you about a Coldfusion or ASP solution. Are you able to contact me?

    Thursday, December 6, 2007 at 7:09 pm #
  72. Rool wrote:

    very great,
    is it possible to get the progress of sending the data to the server? to have a progressbar that displays the status of uploading?

    Thursday, December 13, 2007 at 11:23 pm #
  73. Hi Thibault.

    I really enjoy the work you’ve done here. My problem (as many others), is that my server doesn’t run PHP – it’s a Java application server. Do you happen to know of any Java version, that handles the serverside task of receiving the bytearray and converting it?

    Cheers /Martin, DK

    Wednesday, January 2, 2008 at 7:58 pm #
  74. Krustyflakes wrote:

    Thibault Imbert your app is absolutely amazing, i am working in a project at the time and this is just what i’ve been looking for, i would like to get in contact with you, to see if its posible for me to make use of your solution for my project. Thank you very much

    Tuesday, January 8, 2008 at 1:11 pm #
  75. Thibault Imbert wrote:

    hi Krustyflakes,

    You can use it for sure ;)



    Saturday, February 2, 2008 at 3:55 am #
  76. KC wrote:

    *bows down to Thibault*

    Awesome! I’m soooo close to getting this to work. I’m having similar problem to Kuzco (post #6) and I saw your response. I am am able to access the gateway.php from my browser….but stil the “please wait” message. :-(

    Thursday, February 7, 2008 at 12:38 am #
  77. Thibault Imbert wrote:

    Hi KC,

    Thanks :)
    Make sure you set the “pictures” folder with proper CHMOD (777) so that the PHP script can save the image.

    Double check the location of the “pictures” folder.

    let me know :)

    I have updated the sources files with proper location of the “pictures” folder.

    let me know ;)


    Thursday, February 7, 2008 at 12:47 am #
  78. I keep getting the SecurityError: Error #2123: Security sandbox violation, when I try to draw the bitmap with streaming video (xmoov). Everything is working when using a webcam. Anybody got a solution?

    Tuesday, February 12, 2008 at 5:34 pm #
  79. Stuck wrote:

    Any way to use the URLLoader to POST the ByteArray. I am working with sending this to Django instead of a PHP file…thoughts? help? I get the image set up, but the bytes don’t transfer to the server.

    Thursday, February 14, 2008 at 6:38 am #
  80. Thibault Imbert wrote:

    Hi Stuck,

    yes that is possible with some specific HTTP headers, I will post an exemple tonight, I will let you know here.



    Thursday, February 14, 2008 at 11:31 am #
  81. The project I’m working does not allow directory writing access. I’ve been trying to figure out how to take the byte array and use php to just force the download dialog instead of it being saved to the server. Does anyone know if this is possible?

    Thursday, February 28, 2008 at 2:43 am #
  82. James wrote:

    Hi Thibault,
    Great solution! However it is too slow for the application I had in mind for it (20 seconds for the test I’ve just made). I have to allow some users to look at a JPEG, arrange bits of text on to it, and then send it back to the server to be e-mailed elsewhere. Have you any ideas for work that may be done to optimise the algorithm? I noticed that someone (“Sander”) had also commented on v.0.3 with the same query, talking about reducing the number of floating-point number calculations. Did anything come from this? Has anyone else looked into this?

    Thanks for your generous work,

    Friday, March 14, 2008 at 4:49 pm #
  83. Thanks again for the great work.
    Check out the quick installation and and example:

    Saturday, March 15, 2008 at 11:16 am #
  84. batchas wrote:

    Un GRAND merci Thibault pour l’aide inconmensurable que tu apportes directement ou pas à tous ceux qui programment dans Flash/Flex (et je pèse mes mots!).
    J’aimerais poster une variable supplémentaire vers JPEGEncoder.php à partir de Flash et je me demandais quel chemin tu prendrais? Par ex. pour que dans le script PHP tu puisses lire une variable “userID” envoyée en même temps que le bytearray… J’imagine qu’il faut l’envoyer avec le streamObjecT?
    Merci beaucoup!

    Monday, April 14, 2008 at 12:47 pm #
  85. Hissam wrote:

    Hey friend

    I need help. I’m a callow in the world of programming. I’m coming from a background

    I have a task to create a flash file as per the client interactions on a flex application.

    Its just simple, I have created a creater where user makes 3 canvas with different Bgcolor n some text.
    i have to create a flash of this 3 canvas where they will run 1 at a time in some time line
    that I have to do at the asp/ end by using the library.

    My question is, How could I send the 3 canvas objects to the page.
    I donno much bout XML too

    Pls help as soon as possible!!

    Friday, April 18, 2008 at 8:51 am #
  86. batchas wrote:

    Salut Thibault,
    Je ne sais pas comment tu arrives à gérer tous ces threads, mais à moins de parfois zapper complêtement (…), il y aurait parfois de quoi devenir vraiment dingue. Je ne parle pas uniquement de mon dernier message oû la question contenait déjà la solution (“dois-je envoyer les variables supplémentaires avec ton object ‘streamObject’?”… non non.. pas la peine, avec la poste c’est plus rapide!”), mais aussi des quelques autres oû parfois j’aurais pour ma part énormément de problème à comprendre ne serait-ce que la question. Ou encore à en accepter le ton peu respectueux: “j’ai un problème. je veux la solution, vite!”. Bref, tout ça pour dire que grâce à ta classe (sans jouer sur les mots), je peux enfin clore une partie importante d’un projet. La sauvegarde d’une couverture de bouquin dont la composition (couleur, texte etc) se fait entièrement dans Flash par l’utilisateur. Je t’enverrai le lien une fois en ligne officiellement…
    Amitiés. Batchas

    Thursday, April 24, 2008 at 9:19 pm #
  87. Sweet Thibault!
    Just one question. Am trying to get this to work without use=ing the AMFPHP service, as I only need to save th jpeg to the server, but am stuck. any recommendations how that could work?

    Wednesday, April 30, 2008 at 12:52 pm #
  88. Thibault Imbert wrote:

    Hi flashacrobat,

    I did another version of this Live JPEG Encoder without using AMFPHP. I have to upload the sources, I will do that tonight and let you know in the comments :)

    kind regards,


    Wednesday, April 30, 2008 at 12:56 pm #
  89. Hi again.
    The way I understand your code, it should be possible just to post myCapStream to a simple PHP that saves the file on the server, as myCapStream contains the image data? But somehow can’t manage, am I missing something?

    Wednesday, April 30, 2008 at 7:59 pm #
  90. Pete wrote:

    This is great! However I need a way to just save the jpg on the local computer without having to use the AMFPHP via the internet. Is there anyway to do this. Thanks

    Sunday, May 4, 2008 at 6:50 am #
  91. Christopher Miles wrote:

    hi Thibault!

    Awesome project! I was wondering, what variables would I need to change to make this work for my own website? Basically I just want to have a webcam showing in flash, press a button and have it save to a folder. Just to test it out. Your help would be greatly appreciated! thanks!

    Tuesday, May 6, 2008 at 9:37 pm #
  92. chuckles wrote:

    Way late to be commenting here, but how easy is this to integrate into RoR?
    Already committed to a project in that framework, so CakePHP isn’t exactly on my menu

    Monday, June 23, 2008 at 9:38 am #
  93. Kaushal Shah wrote:


    I have try this with Flash it works successfully. I want to also use this code with Flex, but where it doesn’t work, can anyone guide me how I can use same in Flex?

    Wednesday, July 16, 2008 at 9:09 am #
  94. tukinu wrote:

    this is realy a great tool and it just works. one question i have. how can i send with the data an individual jpg name? thanks a lot

    Monday, September 15, 2008 at 12:06 pm #
  95. batchas wrote:

    hi Tukinu, I guess Thibault is very busy… So here is how I would do… in Flash:
    St te image name as you wish to.
    var sImage:String = “myImage.jpg”;
    Pass this vr with your streamObject:
    var streamObject:Object = {jpegstream : myCapStream, imageName : this.sImage };

    and in PHP…
    Catch the var from Flash:
    $myImage = $pInfos["imageName"];
    and if you keep the $idimage var:
    $idimage = $myImage;

    Hope it helps. batchas

    Saturday, September 20, 2008 at 5:49 pm #
  96. Thibault Imbert wrote:

    Hi batchas,

    Thank you for helping, your code is perfect :)

    Saturday, September 20, 2008 at 10:25 pm #
  97. sitron wrote:

    just to add another “THANK YOU” on the list!

    Wednesday, October 22, 2008 at 4:28 pm #
  98. Hi in flash 10 player there is a security error for local dik writing
    Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
    at media_snapshot_webcam_fla::MainTimeline/onHDSuccess()

    Sunday, October 26, 2008 at 7:48 am #
  99. Thibault Imbert wrote:

    Hi Anil,

    Yes, for security reasons we can not call browse or download outside mouse events or keyboard events. This is really sad news, I will modify the application so that it works smoothly.



    Sunday, October 26, 2008 at 11:38 am #
  100. dazfunkyman wrote:

    Je souhaiterai utiliser ton encoder avant de faire un upload via filereference afin d’alléger au maximum le poids des transferts clients/serveur mais je n’y arrive pas puisque apparemment filereference ne dispose pas de lien vers le fichier sélectionné via le bouton parcourir mais juste le nom du fichier choisi.
    Connais-tu une astuce pour palier à ce problème? et j’ai essayé de voir le code de la classe filereference pour voir s’il est possible de l’étendre mais je n’ai pas trouvé son package. Peux tu également me l’indiquer. Merci d’avance

    Thursday, October 30, 2008 at 7:42 pm #
  101. mike wrote:

    Hello Thibault,
    First of all, fantastic work! :D
    I would just like to know if you tried loading a jpeg snapshot you created from amfphp to be passed back to the swfapplication like in this way…

    return new ByteArray( file_put_contents(“../../../pictures/”.$idimage, $imageData));

    Is there a way to convert this data back into a bitmapdata? I tried almost every possible combination i can find but still i might be missing something…

    Friday, November 7, 2008 at 5:11 am #
  102. mike wrote:

    What i meant to say about my previous post was
    return new ByteArray( file_get_contents(”../../../pictures/”.$idimage);

    Friday, November 7, 2008 at 7:44 pm #
  103. Devinder Pruthi wrote:

    i am doing one project in flex cs3. i am using bledgeDS. i am using webservice. i am getting bytearray for a xml file. i want to know how i decode this bytearray and find content of that xml file. please help

    Tuesday, November 18, 2008 at 10:08 am #
  104. rob wrote:

    I’m using your software succesful on my website, everything works just fine.

    The only thing I like to change is the filesize of the captured images. Every image is 800×600 and uses almost 500kb space on my server.

    How can I reduce the resolution of the images and how can I reduce the jpeg qualtity?

    In the example it works very easy with the slider but I don’t know how and where I will have to put the variables in the code.

    I hope someone has a tip for me, thx in advance.

    Thursday, January 8, 2009 at 1:34 am #
  105. Randall wrote:

    The player doesn’t seem to be able to support a stream from a flash media server?

    rtmp:// versus http://

    I’ll look into it – but any ready-made solution?

    Friday, January 9, 2009 at 9:52 pm #
  106. batchas wrote:

    Hi Rob,

    >>> About the compression level:

    If you open the FLA which comes wth the source code, you see how Thibault is setting every variable.

    To set the quality, Thibault sets a variable called “qualityValue”:

    var qualityValue:Number = mySlider.value;

    So as you are not using the slider, you just need to give a value to the qualityValue variable like this:

    // you just replace “mySlider.value” with the amount of compression you desire
    // if the compression level is 70%:

    var qualityValue:Number = 70;

    // create the encoder with the appropriate quality
    var myEncoder:JPEGEncoder = new JPEGEncoder( qualityValue );

    The other shorter way is to write directly the value in the JPEG Encoder:

    var myEncoder:JPEGEncoder = new JPEGEncoder( 70 );

    >>> About the filesize:

    I cannot answer here because I do use the Matrix and the Rectangle for the bitmpaData…
    I do not know how you get a screenshot with these dimensions (800×600) but the dimensions should normaly be defined in these code lines:

    var myBitmapSource:BitmapData = new BitmapData ( myWidth, myHeight );

    myWidth and myHeight being the bitmap size you wish to get as final dimensions.

    Hope it helps!

    Tuesday, February 3, 2009 at 9:15 pm #
  107. Ludovic wrote:


    Super classe, c’est exactement ce que je cherchais…

    Cependant, j’eprouve des difficultés avec les grandes images (largeur supérieur à 1500 voire 2000) : Flash plante sur une erreur “1502″ délai d’execution dépassé (15 secondes).

    Je pense que la boucle de compression est trop longue à son gout.

    Comment peut on lui dire que tout est normal, et qu’il doit attendre sagement que la compression soit terminée ?

    J’ai essayé d’ajouter des DispatchEvent, mais ca n’a pas l’effet escompté !?

    Merci :)

    Friday, February 27, 2009 at 5:37 pm #
  108. Rockntrek wrote:

    Même problème que Ludovic…

    Friday, March 20, 2009 at 2:33 am #
  109. Todd wrote:

    I’m desparate: when I go to publish the fla file, I get the following error:

    the intrinsic attribute is no longer supported

    using flash cs3. What am I doing wrong??

    Thursday, June 4, 2009 at 2:45 am #
  110. John15942 wrote:

    Salut Thibault,

    Super script !
    Pourrais-tu me dire comment je pourrais prendre le jpg sur le serveur et l’envoyer directement par email, tout cela apres avoir clicke sur “capture” ?
    J’ai du mal a comprendre comment lier le Flash > PHP > JPG > Email :-(

    Merci par avance

    Sunday, September 6, 2009 at 6:16 am #
  111. Benoit wrote:

    That’s too bad the files apparently don’t work with CS3… Could you please save them as they are backward compatible please? That’d be VERY nice from you!

    Tuesday, October 27, 2009 at 7:55 pm #
  112. Reinier wrote:

    I’m also wondering how to make a progress bar on this method of uploading jpg’s with amfphp..

    Monday, November 30, 2009 at 2:06 pm #
  113. Gertschi wrote:

    Hi! what does :Waiting: new Waiting(); in the source Code?

    Best Regards

    Thursday, December 3, 2009 at 7:56 pm #
  114. aaa wrote:

    i dont want amfphp

    Sunday, January 10, 2010 at 8:21 pm #
  115. rainssong wrote:

    it’s amazine :)

    Wednesday, May 19, 2010 at 10:33 am #
  116. Someone managed to implement a progressbar in sending the ByteArray to the server?
    Just got back when the file has just been sent, I can not sending a progress.

    Alguém conseguiu implementar a progressbar no envio do bytearray para o servidor?
    Só tenho retorno quando o arquivo acaba de ser enviado, não consigo um progress do envio.

    Thursday, November 25, 2010 at 1:39 pm #
  117. duman wrote:

    thanks for this class..

    but I dont execute my example..

    I m drag-drop image upload with air in myMc.myuloader its succesfuly.. But When I upload image

    my uploadded image is created but is empty..(border black and inside white)..why my image dont upload with original photo or img..

    thanks for your answers..

    Sunday, February 13, 2011 at 7:53 pm #
  118. duman wrote:

    I M drag-drop image in air ..
    in myMc.MyUloader..

    But When I Was Upload with Jpegencoder-amfphp ..My İmage is Created But its emty..(blask stroke and white background)..

    how I Upload My static image with amfphp with jpegencoder..

    thanks for your ansvers..

    Sunday, February 13, 2011 at 7:57 pm #
  119. Parada1280 wrote:

    Hello Thibault im using amfphp, double checked the folder permissions they are ok, i call the Method: saveToServer in the browser amfphp and get a result 0, it work when i leave the paths to bytearray, but when i change the gateway and folders to my server (local and www) it keeps saying Please Wait… what can it be, i just checked the others post but none say anithing about this problems, really thanks for your help

    Tuesday, May 17, 2011 at 7:34 am #
  120. Matth wrote:


    Pour ceux que ça intéressent, j’ai effectuer une traduction en français de cet article avec un exemple :

    A bientôt,

    Thursday, June 30, 2011 at 5:54 pm #
  121. العاب wrote:

    hello every one,
    can i use it to captuor flash games?

    Thursday, August 11, 2011 at 3:36 am #

Trackbacks/Pingbacks (12)

  1. [...] AMFPHP Live JPEG Encoder 0.4 [ by Thibault Imbert ] [...]

  2. [...] Um modo é você tratar o Flex como se fosse um form HTML, outro modo é através de ByteArray como este Link. [...]

  3. [...] Um modo é você tratar o Flex como se fosse um form HTML, outro modo é através de ByteArray como este Link. [...]

  4. [...] veja o artigo [...]

  5. FXCBooth version 2 + Live JPEG Encoder: Labs@flexcoders on Saturday, March 15, 2008 at 11:15 am

    [...] Download AMFPHP Live JPEG Encoder 0.4; [...]

  6. flashcrobat » Blog Archive » capture Jpeg live from webcam on Tuesday, April 29, 2008 at 8:43 pm

    [...] video to later display in an html video list. After turning the web upside down, I found that byteArrays blog’s approach seemed the most suitable one. But he works with AMFPHP, which I did not want to add to the [...]

  7. Leonardo França » Salvar a imagem da webcam no servidor on Thursday, September 11, 2008 at 7:40 pm

    [...] veja o artigo [...]

  8. Flash中のBitmapをJPG/PNGで保存するには » TECH Matari on Thursday, August 13, 2009 at 5:34 pm

    [...] blog: Flash 上で Bitmap を JPEG 画像に変換 AMFPHP Live JPEG Encoder 0.4 <font size=’1′>[ by Thibault Imbert ]</font> &l… FICC LABS | Flashから画像ファイルを保存する [...]

  9. AMFPHP Live JPEG Encoder 0.4 « on Friday, December 25, 2009 at 7:06 pm

    [...]  ya da webcam uygulamasından görüntü yakalamak, kaydetmek için gerekli olan  kodları burada bulabileceksiniz. Video görüntüleri için demoyu buradan,  webcam için demoyu buradan [...]

  10. Image Editor revised. « Hangun’s World – Blog on Wednesday, January 13, 2010 at 11:56 am

    [...] AMFPHP Live JPEG Encoder 0.4 [ by Thibault Imbert ] [...]

  11. [...] ich mir hier die neuste Version der JPEGEncoder Klasse gezogen: AMFPHP Live JPEG Encoder 0.4 <font size='1'>[ by Thibault Imbert ]</font> – ByteArray.or… Das ist ein Zip mit einer Beispiel Anwendung. Daraus hab ich mir die JPEGEncoder Klasse geholt [...]

  12. WebCam » Bruno bg + ADOBE FLEX on Sunday, May 9, 2010 at 5:22 pm

    [...] [...]