I have a mpg file in my system and i want to publish it into the Red5 server so that i can broadcast it over my network.After some research work i was not able to find a solution for it ,did anyone of you guys have tried this .I mean publishing file from local system to red5 server.Can anyone guide me to a proper direction possible please.I am using Flash CS3 and AS3.
2 Answers
You can use the FileReference.browse() to get a dialog/system pop-up to choose a file. You listen for the SELECT event on it (this means the user chose a file), then you can call upload on it. You'll need a server side script of some sort that accepts the file and saves it to a location the Red5 server is pointing to to serve it's files (PHP, Java, whatever should do).

- 19,630
- 4
- 38
- 51
-
can u provide me a sample tutorial for this as i am unable to find ,i am using flash cs3 and as3 – Vipin Nair May 21 '12 at 04:12
-
@Vipin actually working on redesigning and rebuilding my site at the moment, I'm feeling that my work on stackoverflow is flowing out into the ether and I'm not capturing the concepts in a way I can easily reference them, I'll include a write-up and example code for achieving the task, do you have the ability to run a server side script, if so what language would you use to implement it, I'm familiar with PHP and Java and should be able to provide a solution in either. For now: http://www.kirupa.com/developer/flash8/uploading_fileReference_pg1.htm – shaunhusain May 21 '12 at 05:19
-
Thanks for writing in immediately.I am stuck in an issue where i have to play mpg file with flash,yet we know it only plays flv files.I have just started to use flash ,so i dont know about the crux of it,yet i have to complete the task.I dnt know php or java ,yet i can understand the java code.I tried flash video encoder to convert the video,but can i do that in coding in action script .Have u done that anytime? – Vipin Nair May 21 '12 at 05:26
-
Link to my main question: http://stackoverflow.com/questions/10679606/converting-mpeg-file-to-flv-and-simulataneously-playing-the-converted-file-in-fl – Vipin Nair May 21 '12 at 05:30
-
@Vipin I don't believe you'll be able to easily or quickly convert the video file in AS3 (it's certainly possible but I'm not aware of any libraries that will leapfrog you to doing the decoding/encoding client side) my assumption is that you'll have to get the file uploaded to the server then use something like ffmpeg to do the actual re-encoding. I don't have much exposure to Red5 but have a friend at work who has used it quite a bit, I'll see if I can chat with him tomorrow to see if he has any suggestions. – shaunhusain May 21 '12 at 05:32
-
Found a couple more relevant links, notified my co-worker buddy of this post so he may chime in if he has some time: http://trac.red5.org/wiki/Examples/FileUploadServlet http://www.bala-krishna.com/convert-video-files-to-flv-using-ffmpeg-command/ – shaunhusain May 21 '12 at 17:27
-
@Vipin Shaun's friend here-- I think that file upload servelet should work fine though you may want to make changes to where it stores the files until they have been transcoded, but you could use other upload methods if that one doesn't work... the rest of my feedback to your question is too long for a comment though, so I'll put it in an answer. – waxspin May 21 '12 at 19:05
@Vipin Your best bet is going to be using something like ffmpeg for ease of programming, quality, and transcoding speed, and if you want a nice API something like xuggler looks like a good approach, and though I've never used it, I've read lots of good things about it from people doing stuff exactly like what it sounds like you're trying to do. I have successfully used ffmpeg to do something similar to what you want from a Ruby backend recently, and have no reason to believe it'll be any less easy or usable for you to do this in Java. To use runtime.exec()
to execute ffmpeg, try this. If you do either of them, there shouldn't be any reason that FLV isn't an option, as I know for sure that ffmpeg does this. It's a little older post, but this post covers how to set up a command line exec call to ffmpeg for going mpg -> flv like you want, though I imagine if you use xuggler, this is built in to the API a little more. Another SO answer that covers both of these approaches is here.
-
hey thanks waxspin,i managed to convert the mpeg file to flv file and simulataneosuly i have to play the file using flash,but the problem is that i have to wait some time while the mpeg file is being encoded otherwise the flash player just gets stopeed while playing the video.Can u help me in this case,like how can i play the file while encoding it simulataneosuly. – Vipin Nair May 22 '12 at 03:52
-
hi do u know other encoders apart from FFMPEG ,i want to try other tools also as there is a delay while playing the encoded video through ffmpeg. – Vipin Nair May 22 '12 at 10:56
-
By delay, are you referring to the delay between the input and output? Or do you mean there's a delay between the audio and video tracks? There are other command line tools, but I would be surprised if there are many that are more powerful, stable, and flexible all at the same time, as FFMPEG (in other words, finding one that does FLV files as simply and decoupled as FFMPEG might take some googling.) – waxspin May 22 '12 at 17:23
-
Also, just thought of something-- if your issue is in fact a delay between tracks, is it possible that you're changing the video framerate? If you are this may cause sync issues; as well there is a way using ffmpeg to correct this problem during transcoding that you can use, since sync is a very old problem in the a/v world... – waxspin May 22 '12 at 22:05
-
i am not saying about the delay in the video and audio tracks ,its about the video which is being encoded in ffmpeg at one side and at other side i am playing the encoded video using flash – Vipin Nair May 23 '12 at 03:33
-
There's basically no way you can avoid that, as for any transcoding process, even 'real time' broadcasts, there will always be some amount of time required, regardless of whether it's a high speed hardware or software implementation, to do the transcoding. If I'm still misunderstanding your question, I apologize :) However, there may be a way to minimize this delay by picking how soon you start playing the file while it's being transcoded. But this is likely to run into some issues such as: what if the transcoder gets held up due to low server resources, etc. – waxspin May 23 '12 at 14:45