Live Video from Linux to Flash Lite 3.0

You can't use Flash Media Encoder 2 in Linux, so you have to make your own publisher with Flash. Idea is to make own Flash application which connects to webcam and send/publish this live video to Flash Media Server 3 and then clients can connect to Flash Media Server 3 and start to view this live broadcast. Here are simple default instructions to send live video from Linux to Flash Lite 3.0 application.

Install Linux and Flash Media Server 3:

  • Install some Linux distribution (I installed Fedora Core 8 )
  • Download and install Flash Media Server 3 (you might have to use -platformWarnOnly)
  • go to your fms directory: cd /opt/adobe/fms
  • start Flash Media Server 3: ./fmsmgr server fms start

You can use command: "ps aux | grep fms" to see list of fms processes running. There should be following processes listed: fmscore, fmsedge, fmsmaster and fmsadmin. If not, there are some problems :-) in your configuration and maybe you want to read this: Flash Media Server does not start after successful installation on RedHat Linux

Creating own publisher with Flash is quite simple. Open NetConnection to Flash Media Server 3. After you get NetConnection.Connect.Success, you can start connection to your webcam and publish stream to Flash Media Server 3.

Publisher:

import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.ObjectEncoding;
import flash.media.Video;
import flash.media.Camera;
import flash.events.NetStatusEvent;
import flash.events.AsyncErrorEvent;

var nc:NetConnection;
var ns:NetStream;
var video:Video;
var camera:Camera;

// create NetConnection-object
nc = new NetConnection();
nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

// connect FMS 3 default live application
nc.connect("rtmp://localhost/live");

// error handling
function asyncErrorHandler(event:AsyncErrorEvent):void {
  trace(event.text);
}

// if connected, start publishing
function netStatusHandler(event:NetStatusEvent):void {
  if (event.info.code == "NetConnection.Connect.Success") {
    startPublishing();
  }
}

// publish webcam's live to server
function startPublishing():void {
  ns = new NetStream(nc);
  ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  camera = Camera.getCamera();
  if (camera != null){
     video = new Video();
     video.attachCamera(camera);
     ns.attachCamera(camera);
     // show video in publisher also
     addChild(video);
     ns.publish("livestream", "live");
  } else {
     trace("Please check your camera and microphone");
  }
}

Publish your live video publisher in Flash and upload it (swf, html, js) to your web server. Open your publisher in Web browser and you should see your live video in publisher. Start Flash Media Server Admin console and you should see one live application running and publishing live video.

fms admin

Next you have to make Flash Lite 3.0 application to connect your FMS 3 server and play your live stream. Create Video-object in screen and type following code in first frame in Flash.

Client:

import flash.net.ObjectEncoding;

var video:Video;
var ns:NetStream;
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0;

nc.onStatus = function(info:Object):Void {
  if (info.code == "NetConnection.Connect.Success") {
    startStreaming();
  }
}

function startStreaming() {
  ns = new NetStream(nc);
  ns.setBufferTime(2);
  video.attachVideo(ns);
  ns.play("livestream",-1,-1,true);
}

status_txt.text = "Status : Connect....";
nc.connect("rtmp://your.server.ip.here:1935/live");

Note!
You might have some issues with Linux firewalls, then you must edit /etc/sysconfig/iptables to allow connect FMS ports. Add following lines to iptables to allow ports: 1111 and 1935 access from remote and restart your iptables with command: /etc/rc.d/init.d/iptables restart

# flash media server 3
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1111 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT

Download sources: all

37 Comments

  • Thanks for the explanation. I tested the Flash lite 3 application against Red5 server (I’m using version 0.6.3 on linux) and it worked well.

    If you want to connect your Flash lite app to the Red5 broadcast/subscribe demo replace the code with:

    nc.connect(“rtmp://your.server.ip.here:1935/oflaDemo”);

    and

    ns.play(“red5StreamDemo”,-1,-1,true);

  • By the way, did you get audio with your video? I did not and I’m wondering what’s wrong…

  • I only attached video in publisher. Audio should work with Microphone and attachAudio in NetStream.

  • Yes, I did that but it didn’t help. It could be that this requires some tricks on server side. The only clue I have so far is from here:

    To stream progressive or live audio to a FL3 client you must use FMS3 and set your audio export to MP3. Video is streamed using On2 VP6.

    And as I am using Red5, this doesn’t help too much…

  • I think that the problem may be that the audio codec that the flash publisher uses (NellyMoser?) is not supported by the FL3. I tried Adobe Media Encoder 2.5 application for publishing the video + audio and used mp3 for audio and it worked.

  • Jaakko,

    sorry very busy moment right now with my teaching (for a two weeks). I will check and try this soon in first weeks in May.

  • Hi, and thanks a lot for your example.

    I’m working actually in a mobile application, and I want to stream audio and video from mobile devices to RED5 (Flash Media Server), to implement a video conference.
    I haven’t found information about that.

    Can anybody give me some information about that?

    Thanks for your time.

  • Do you know whether it’s possible for Flash Lite 3 to publish a live stream to a Flash Media Server? Basically, the opposite of what you’re doing here.

  • I think there is no solution yet, but hope kuneri guys will do this plugin soon :-)

    Pasi

  • Hi Pasi, for first really thank for your tutorial!
    I’ve a problem with the write access of FMS, because i’m working on a Ubuntu 8.04 system and I installed everything but when I open Flash Media Encoder I can connect to my server but when I press start for the live streaming I get this error:
    Tue Sep 23 2008 17:28:18 : Primary – Connected
    Tue Sep 23 2008 17:28:20 : Primary – Stream Status: Success
    Tue Sep 23 2008 17:28:20 : Primary – Stream Status: NetStream.Record.NoAccess
    Tue Sep 23 2008 17:28:20 : Primary – Unable to stream. Network problem at server.

    And in the Adobe Flash Media Administration Console I get also:
    write access denied for stream myStream1

    What I can do now?
    thanks for any suggestion!

  • Antonio,

    maybe there is some problems with “fms user” in your system. You should check that there are right permissions with filesystem. I installed fms with user fms and group fms and here are filesystem permission from my linux:

    drwxr-xr-x 2 fms fms 4096 2008-03-15 14:47 live

    So you can see that fms user has read, write and execute permission to default live folder. I dont know if this is your issue, but maybe you should check these first.

    Pasi

  • Thanks a lot!It work now, just adding the right permission and I can connect to the server using Flash Media Encoder but now I would try to connect myself using your fla for sending my streaming witouth FME, but when I execute the swf my camera doesn’t start!I see just a white swf, where’s the problem?
    thanks for your reply

  • Antonio,

    check first that your camera is working in Ubuntu with some Ubuntu tools. Then when you got it working there, SWF should work in browser and you should see your live camera there.

    Pasi

  • Thank a lot!It work now!it was a problem with my server!

  • So,I was tried to used Adobe Media Encoder + RED5 to stream a live video to FL3,the voice is good,but the video has some problem.The video was very jump!And I try to make a publish with Flex the video is good but the voice is bad,no voice!So,how can I make the micphone stream to MP3 code?If we can do this,the voice publish will be good!
    Who can help me? Thanks!

  • Hi, it seems that when playing the live streams, it freezes on the first frame…i’ve read here and there that this was a fl3 issue..But when i hear you guys saying it’s working…in fact it freezes using a wowza server, and it doesn’t even connect using fms3 trial…any clue ?

    thanks !

  • Fringues,

    I installed FMS3 to my RedHad Linux system and it works. Sorry I haven’t test wowza server.

    Pasi

  • Hi…this is sravan. your sample code is not opening. it is giving error message like unexpected file format before opening it.could u explain me Creating own publisher with Flash in detail….

  • Actually for live streaming we r using red5 but we want to change red5 and use the fms…
    I tested every thing in windows but i have problems in linux.
    send me the details steps what i should follow in linux os to run our live streaming using fms.

  • sravan,

    source file is CS3-file so it sould work with CS3 or newer version of Flash.

    Pasi

  • Hey while starting FMS in linux i got error like this in log file…
    anybody suggest me what i have to do..
    Oct 19 11:42:30 server806 xinetd[31143]: START: smtp pid=1709 from=118.168.100.248
    Oct 19 11:42:30 server806 xinetd[31143]: START: smtp pid=1711 from=118.168.100.248
    Oct 19 11:42:31 server806 xinetd[31143]: EXIT: smtp status=1 pid=1711 duration=1(sec)
    Oct 19 11:42:31 server806 xinetd[31143]: EXIT: smtp status=1 pid=1709 duration=1(sec)
    Oct 19 14:22:23 server806 xinetd[31143]: START: smtp pid=2425 from=124.8.96.48
    Oct 19 14:22:26 server806 xinetd[31143]: START: smtp pid=2427 from=124.8.96.48
    Oct 19 14:22:39 server806 xinetd[31143]: EXIT: smtp status=1 pid=2427 duration=13(sec)
    Oct 19 14:22:40 server806 xinetd[31143]: START: smtp pid=2429 from=124.8.96.48
    Oct 19 14:22:40 server806 xinetd[31143]: EXIT: smtp status=1 pid=2425 duration=17(sec)
    Oct 19 14:22:41 server806 xinetd[31143]: START: smtp pid=2431 from=124.8.96.48
    Oct 19 14:22:47 server806 xinetd[31143]: EXIT: smtp status=1 pid=2429 duration=7(sec)
    Oct 19 14:22:49 server806 xinetd[31143]: EXIT: smtp status=1 pid=2431 duration=8(sec)
    Oct 19 15:18:32 server806 xinetd[31143]: START: smtp pid=2580 from=118.166.225.237
    Oct 19 15:18:35 server806 xinetd[31143]: START: smtp pid=2583 from=118.166.225.237
    Oct 19 15:18:35 server806 xinetd[31143]: EXIT: smtp status=1 pid=2580 duration=3(sec)
    Oct 19 15:18:35 server806 xinetd[31143]: EXIT: smtp status=1 pid=2583 duration=0(sec)
    Oct 19 21:31:20 server806 xinetd[31143]: START: smtp pid=3850 from=123.204.66.115
    Oct 19 21:31:20 server806 xinetd[31143]: START: smtp pid=3851 from=123.204.66.115
    Oct 19 21:31:20 server806 xinetd[31143]: EXIT: smtp status=1 pid=3850 duration=0(sec)
    Oct 19 21:31:20 server806 xinetd[31143]: EXIT: smtp status=1 pid=3851 duration=0(sec)
    Oct 19 23:47:06 server806 ntpdate[4152]: step time server 207.46.197.32 offset 3.307330 sec
    Oct 20 10:53:56 server806 xinetd[31143]: START: smtp pid=6585 from=127.0.0.1
    Oct 20 10:53:56 server806 xinetd[31143]: EXIT: smtp status=0 pid=6585 duration=0(sec)
    Oct 20 10:53:58 server806 setroubleshoot: SELinux is preventing /usr/sbin/httpd (httpd_t) “read write” access to /usr/local/psa/var/utilities.sem (initrc_t). For complete SELinux messages. run sealert -l 5cea69b7-7f76-40e7-bcf8-cc6d948b4e83
    Oct 20 10:53:58 server806 setroubleshoot: SELinux is preventing /usr/sbin/rndc (ndc_t) “append” to /usr/local/psa/admin/logs/httpsd_error_log (usr_t). For complete SELinux messages. run sealert -l 3fd30d91-5b16-49f2-bd8e-e945d69e7cdc
    Oct 20 10:54:07 server806 xinetd[31143]: START: smtp pid=6859 from=127.0.0.1
    Oct 20 10:54:07 server806 xinetd[31143]: EXIT: smtp status=0 pid=6859 duration=0(sec)
    Oct 20 10:54:10 server806 setroubleshoot: SELinux is preventing /usr/sbin/rndc (ndc_t) “append” to /usr/local/psa/admin/logs/httpsd_error_log (usr_t). For complete SELinux messages. run sealert -l 3fd30d91-5b16-49f2-bd8e-e945d69e7cdc
    Oct 20 10:57:32 server806 xinetd[31143]: START: smtp pid=6977 from=127.0.0.1
    Oct 20 10:57:32 server806 xinetd[31143]: EXIT: smtp status=0 pid=6977 duration=0(sec)
    Oct 20 10:57:34 server806 setroubleshoot: SELinux is preventing /usr/sbin/httpd (httpd_t) “read write” access to /usr/local/psa/var/utilities.sem (initrc_t). For complete SELinux messages. run sealert -l 5cea69b7-7f76-40e7-bcf8-cc6d948b4e83
    Oct 20 11:33:08 server806 shutdown[7323]: shutting down for system reboot
    Oct 20 11:33:08 server806 init: Switching to runlevel: 6
    Oct 20 11:33:09 server806 smartd[2944]: smartd received signal 15: Terminated
    Oct 20 11:33:09 server806 smartd[2944]: smartd is exiting (exit status 0)
    Oct 20 11:33:16 server806 xinetd[31143]: Exiting…
    Oct 19 23:33:20 server806 hcid[2489]: Got disconnected from the system message bus
    Oct 19 23:33:20 server806 rpc.statd[2396]: Caught signal 15, un-registering and exiting.
    Oct 19 23:33:20 server806 named[20713]: shutting down: flushing changes
    Oct 19 23:33:20 server806 named[20713]: stopping command channel on 127.0.0.1#953

  • Hi,
    Creating own publisher with Flash is quite simple. Open NetConnection to Flash Media Server 3. After you get NetConnection.Connect.Success, you can start connection to your webcam and publish stream to Flash Media Server 3.

    I installed FMS in linux server. regarding the above where i have to put these cs3 files and how to run my live streaming.

    sravan

  • i started my FMS by using the following command, once u check it and reply me 1) whether my FMS is started or not?
    [root@main fms]# ./fmsmgr server fms start
    Server:fms command:start
    NPTL 2.5
    Starting Adobe Flash Media Server (please check /var/log/messages)
    [root@main fms]#
    2)this is my console output.
    [root@main fms]# ./fmsmaster ?console
    [root@main fms]#

    3)I understood ur mannual upto server starting, after that how to create a own publisher and and how to run live streaming.

    reply me i am in the final stage of our project.

    sravan

  • Hi i found what is my problem:-
    i uninstalled my FMS and again try to install it again. while installing i got error like this(my os is linux cent OS):-
    Proceed with the installation? (y/n/q): y
    Installing Adobe Flash Media Server files…
    Configuring Adobe Flash Media Server…
    Adding “fms” service.
    Setting default admin to “fms”.
    Setting autostart for “fms”.
    Server:fms command:start
    ./fmsmgr: line 115: cd: y: No such file or directory
    NPTL 2.5
    Starting Adobe Flash Media Server (please check /var/log/messages)

    Admin server:fmsadmin command:start
    ./fmsmgr: line 102: cd: y: No such file or directory
    Starting Adobe Flash Media Admin Server (please check /var/log/messages)

    suggest me what are these error messages.

  • while running the ptmclient i got this error.
    The currently targeted Flash Player does not support the FSCommand2 action.
    so which version of flash player supports FSCommand2

  • sravan,

    sorry I exactly don’t know where those error’s comes from with your installation – have you checked your messages file?

    Are you getting that FSCommand2 error with your ptmclient in mobile or in desktop www browser which send live video to FMS3? In mobile you should have Flash Lite 3.0 Player installed and run ptmclient as an stand alone application. PTMClient (which send video to FMS) should work with latest version of Flash Lite Player in web browser.

    Pasi

  • I am using ur code as above.
    I am able to access the ptmlive.html,meaning i am able to view mylive video in browser. but when i start ptmclient.html it is showing connection sucess but not showing the video.

    help me…

  • I tested ur application in localhost, it is working.
    but when i tested with remotely,
    I am able to access the ptmlive.html,meaning i am able to view mylive video in browser. but when i start ptmclient.html it is showing connection sucess but not showing the video.
    my connection url is
    nc.connect”rtmp://124.217.227.30:1111/live”, “sravan”, “sravan” );
    where sravan is admin name and password

    reply me

  • sravan,

    check your connection url (right port no need to use logins):

    nc.connect(“rtmp://your.server.ip.here:1935/live”);

    Pasi

  • Hi Pasi, I’ve another problem working with live stream on Flash Lite. I’m using a Nokia N96 and I added the audio to your PTMLive, and I can listen the music always using your PTMClient published on the web.
    If I try to put it on the mobile I can see the video, that sometimes crashes but there’s always no audio! Why this? It’s a phone problem?
    I need to add the attachAudio also on the client?
    Thanks for your reply!
    A.

  • Antonio,

    sorry but I think N96 isnt’t the best phone with Flash Lite and video (now with the latest firmware). I got a lot of strange probles with it when I tested Flash Lite and video with it about month ago.

    Sorry I can’t help you now with this.

    Pasi

  • Uhm sounds good that powerfull phone at the moment for Nokia as all that problems with Flash lite & video!
    At the moment I’ve also other two enabled Flite 3 phones, Nokia E65 and Nokia E71, maybe I can check for a Nokia N95..
    But I’ll do that if you say that it work on that phones, but I saw this post and I think that it’s a common problem at the moment..
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=68&catid=472&threadid=1391230#5076783
    I wrote a mail to Mark Doherty, and if there’s any news I’ll write here!
    Thanks a lots Pasi
    A.

  • Hi Pasi,

    Sound(live audio) isn’t working. Sound works find with FME3.0 but not when published from AS. Anybody knows the resolution to this, and code examples?
    Seems like the codec problem. FL3.1 is said to only support mp3 streaming, but I am not sure how can I change the codec.

  • hi. i got this problem in flash lite. im creating a live streaming application for flash lite 3( for mobile phone) w/c will connect to a red5 server. the source of the stream is coming from a flex application capturing the video from a camera. the output of the stream in the flash lite using the e71 is that the video is not good. plays then after random seconds it freezes and plays again. audio video is not synchronize. basically the entire stream is bad. i tried to open the website using my desktop web browser instead the mobile phone and the stream is 100% OK…i tried also playing a flv file streamed by my red5 server and still got the same problem in the flash lite but works well in the desktop browser. I tried to play a local video stored in the server and plays well both flash lite and desktop. I forgot to mention, i tried using the Flash media encoder and Flash media server and it works well both flash lite and desktop web browser. Here are the things im suspecting to cause the problem:

    1. For Live Streaming, the source settings( publisher video and audio settings ) is not good or maybe not fit for the capabilities of the flash lite in mobile phone.
    2. Video streaming( I dont know why )
    3. Red5 server implementation (i didn’t have time to go deeper on red5 server implementation coz im not that good in java).

    If you some suggestions or settings or other ideas to help me solve my problem please im very much interested. Thank you.

  • dj brikz,

    sorry but I havent used red5 server yet. Hope someone can answer this?

    br,
    Pasi

  • Hi Pasi,

    Thanks for your great tutorial.

    I’ve followed it and managed to run the script at the server side but unfortunatelly not at the client side(mobile) I am using N95 and it doesn’t show the live camera stream. I have tested on FMS and Red5 and the output is this:
    ———————-

    Established socket connection to 127.0.0.1.
    NetStream.onStatus called: (6353 ms) – CODE[NetConnection.Connect.Success]
    fmsVer: RED5/0,8,0,0
    capabilities: 31
    description: Connection succeeded.
    code: NetConnection.Connect.Success
    level: status
    FTPS116: FlashVideo Status : (NetStream.Buffer.Full).
    ————————
    On the handset shows text messages but not a video output.

    Used Adobe Decice Central and my handset to test it but neither of them works.

    On my publisher side I’ve registered:
    ns.publish(“livestream”, “live”);

    the lite script to play the video is:
    ns.play(“livestream”,-1,-1,true);

    Any other configuration I need to check?

    Thanks an advance for your help.

  • Hi,

    I am Facing Live Streaming problem without writing any applications. i can see recorded video through …application/vod but when try to see live streaming, i am getting this type of error

    Write access denied from snd_xxxxxxxxx in RHEL5

    Please help me out friends….

    My Project work is pending due this problem…

    Any one please me

    Thanks
    Elavarasan

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>