Stream your Linux/Windows/Mac Desktop as video using VLC


A buddy of mine (thanks Mike) showed me this today. There is a input Access module in the newer versions of VLC (0.8.6+) called “screen” which makes this possible. To stream your desktop to another machine (ip address: 192.168.1.2 in this case) just use the following command in Linux (sorry command line only):vlc screen:// :screen-fps=30 :screen-caching=100 --sout '#transcode{vcodec=mp4v,vb=4096,acodec=mpga,ab=256,scale=1,width=1280,height=800}:rtp{dst=192.168.1.2,port=1234,access=udp,mux=ts}'or in Windows (slightly different syntax) use this command:vlc screen:// :screen-fps=30 :screen-caching=100 :sout=#transcode{vcodec=mp4v,vb=2048,scale=1,acodec=mpga,ab=192,channels=2}:duplicate{dst=std{access=rtp,mux=ts,dst=192.168.1.1:1234}}This is one massive command, so lets take a look at it in more detail:

  • screen:// is our input module selection (if you just run vlc screen:// you’ll see your own screen on the server inside vlc….kinda cool)
  • :screen-fps=30 specifies that we want to screengrab at 30 fps (from default 5 fps)
  • :screen-caching=100 sets the internal caching to 100ms (from default 300 ms)
  • –sout is our output chain.
  • #transcode tells vlc that we first want to transcode the input using parameters to follow
  • {} contains our transcoding parameters
  • vcodec=mp4v sets the video codec to mpeg4 video
  • vb=4096 sets the bitrate of the transcoded video (4Mb/s)
  • acodec=mpga sets the audio codec to mpeg audio (mp3). Audio does not work yet, this is a place holder.
  • ab=256 sets the bitrate of the transcoded audio (256 Kb/s)
  • scale=1 sets the scaling value
  • width=1280 sets the width of the transcoded video to 1280 pixels
  • height=800 sets the height of the transcoded video to 800 pixels
  • :rtp tells VLC that we want to use rtp protocol to send the encoder output to our receiver machine using Real Time Protocol.
  • dst=192.168.1.2 is the ip address of our destination/playback machine
  • port=1234 is the default port on the destination/playback machine
  • access=udp specifies UDP protocol
  • mux=ts sets multiplexing to mpeg-2 Transport stream

Now on the destination machine just open vlc, goto File/Open Network and by default the Media Resource Locator on top of the window should read udp:// and UDP/RTP with port 1234 should be selected. If it’s not select UDP/RTP (option 1) and put 1234 as the port number. Press Okay and you should see the video stream from the other machine (your server machine). That’s it….Opensource comes to rescue again :-)

, , , , , , , , ,

36 responses to “Stream your Linux/Windows/Mac Desktop as video using VLC”

  1. Hi,
    i got interested by your post :-) , and tried it on my Open Suse 10.3 .
    after doing this “vlc screen:// :screen-fps=30 :screen-caching=100 –sout ‘#tr anscode{vcodec=mp4v,vb=4096,acodec=mpga,ab=256,scale=1,width=1280,height=800}:rt p{dst=172.16.5.16,port=1234,access=udp,mux=ts}’”

    i recieved

    “vlc: symbol lookup error: vlc: undefined symbol: img_resample_full_init “

    any idea what it could be ,, thanks for a great post .. i would surely try it once more , it could be some error in my system
    Bye and thanks a lot
    P.S::
    (i have vlc 0.8.6d Janus with open suse 10.3 )

  2. Hi.

    Interesting piece of command.
    I wanted to test the screen streaming on a windows’ and check its performance in terms of CPU/Nwrk/Mem utilization.

    It would be great if you could please give me some know-hows using the latest VLC GUI

    – BlueBox.

  3. Thank you!
    I am trying to stream my desktop over http using Vlc. Is this possible (i succeded only by using VH Screen Capture Driver, but not with your method) ?

  4. Adi,

    You’re right, I had assumed that VLC would use the same command line syntax across platforms. It does not. I’ve included a working command line for windows now. It’s not HTTP, but for windows only I will be doing a couple of screen shots showing the process through the GUI, I will use http for that example.

    TTYL
    Many

  5. Works great, thanks a lot.
    If I would like to add the sound from the computert as well?
    Any ideas?

  6. Cool, this works great. Has anyone figured out how to add this to a live show on ustream.tv?

  7. @John, the only thing that has worked with Ustream so far is Webcamstudio sourceforge.net/projects/webcamstudio/ if you can get VLC working though that would be great to know how.

  8. Are you able to use this as a remote desktop or just streaming the display?

  9. Hey Dan,

    Nope just streaming from what’s in the article. Although nothing is holding you from using something like synergy (windows/osx/linux) or teleport (osx only) to do the mouse and keyboard bit.

    So essentially you setup the remote machine to be on the left or right side of your viewing machine, then you run the procedure above to get the video streaming and once you move your mouse to the edge of the screen you will see it “jump” to the remote desktop over the streaming video.

    Nice thing about this is that given about 3-5 Mb/s bandwidth you can do full motion video/3d (with obvious encoding delay).

  10. Wow thank you for passing along that info, it was just what I was looking for.

    Off topic, so I understand if you dont post this, we are working with the VLC guys to make a user generated database of secure, virtually partitioned streaming remote desktops. Basically VLC meets UltraVNC meets bittorrent. This really helps, thank you again.

  11. Quick qestion though sorry, couldnt you set the streaming protocol to 3GPP and send it to your cell phone, which is less than a 3-5 mbps connection (until wimax/lte anyway)?

  12. Hey Dan,

    Hmmm, Interesting suggestion. My only worry would be the size of the screen on a phone. Maybe the newer netbooks might be a bit better for now. But yeah that would be a neat idea as well……I came across a progy for ipodtouch/iphone that does the remote keyboard/mouse thing if you have VNC installed on the mac or PC….so it might be cool to use it and a netbook/highres phone to do this kinda thing.

    BTW thanks for the info in your other email…..looks like a interesting app….keep me posted :-)

    TTYL
    Many

  13. Actually a quick question. I followed your code and it worked the first time. Now everytime I do it, it just gives me a static image of the screen capture. I am using the exact code that you used on Vista. Any Ideas?

  14. HI Rebelstar,

    Try this gui based tutorial : (http://www.nerdlogger.com/2008/03/stream-your-linuxmacwindows-desktop-as.html).

    It’s basically the same but I might have screwed up a switch or something. Also check to make sure your source machine is actually working. You said that you get a static image on the destination machine. Are you on a local network (ie: both machines). Are you sure there is no bandwidth shaper somewhere between the machines. The stream will be about 5Mb/s, have you checked to make sure that’s available between the machines.

    I have not tried this on vista at all (don’t have vista installed anywhere), so I can’t say for, but it might be a vista issue…..maybe.

    TTYL
    Many

  15. I'm curious if anyone has tried to do this with a multicast so multiple machines could pick up the stream? I'm thinking this would rock in a classroom environment.

    Thanks!

  16. Hi Atlas IT,

    I've tried multicast and it works beautifully. You do NEED a very good network infrastructure to handle this amount of data being mcast'd around. I've tried it at work (university) with Force10 Equipment and it worked flawless. I then got a bit more adventurous and tried various D-Link/Linksys "SME switches" and they barfed. MP4 and MP2 are pretty time sensetive so these cheapo switches can't seem to deliver things on time. The stream falls apart and you get noise at first followed by a green screen…..

    Hope this helps….

  17. hi,
    how can i send the desktop to PS3 server?
    any idea?please!
    i would like to see my desktop on my playstation3 so i can see it in a big screen Tv.
    any idea?please!
    Allan

  18. Hi Allan,

    I'm not sure what you're trying to accomplish by streaming your Computer Desktop as video to the PS3, but if you have a Video player on PS3 that can play networked video (RTP over UDP) then (theoretically) you should be able to do this.

  19. I tried it with latest vlc version on Kubuntu Lucid 10.04 but i have this error:
    alex@kubuntu-desktop:~$ vlc screen:// :screen-fps=30 :screen-caching=100 –sout '#transcode{vcodec=mp4v,vb=4096,acodec=mpga,ab=256,scale=1,width=1280,height=800}:rtp{dst=192.168.1.216,port=1234,access=udp,mux=ts}'
    VLC media player 1.0.5 Goldeneye
    [0x850a148] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.
    Segmentation fault

    alex@kubuntu-desktop:~$ cvlc screen:// :screen-fps=30 :screen-caching=100 –sout '#transcode{vcodec=mp4v,vb=4096,acodec=mpga,ab=256,scale=1,width=1280,height=800}:rtp{dst=192.168.1.216,port=1234,access=udp,mux=ts}'
    VLC media player 1.0.5 Goldeneye
    [0x8441fc8] dummy interface: using the dummy interface module…
    Segmentation fault

  20. Allan, You should look into PS3 Media Server http://ps3mediaserver.blogspot.com/

    That tool allow you to watch any film from your hard drive, but also internet TV. So there should be a way to hook your computer display using VLC to PS3 Media Server so it behaves like an internet tv.

  21. Hi Anonymous,

    VNC works fine, but not if you want to do 30f/s. VNC is a remote desktop client and as such doesn't need to run fast. This is just another way of accomplishing something similar.

  22. kills my cpu on the streamer pc. is there a command to turn off the transcoding?

  23. Hi Anonymous,

    Yeah it kinda sucks the life out of the encoder. So you need a nice beefy machine there……You do need to transcode to something since VLC is probably using some sort of internal frame array to store the raw frames.

    My suggestion would be to bring the resolution down. I mean the resolution of the physical desktop and the encoded video (make sure they match though to VLC doesn't have to scale things in the encode/transcode process).

    Another thing you might try is a less complex encoding scheme like mpeg2

    TTYL
    Many

  24. Thanks for this post, it helped me understand VLC a bit more.

    I tried doing something very similar to this, but rather, I was streaming to a file on a server and then playing that file live from the server. I noticed, however, after this experiment, which lasted about 15 minutes, that, after I stopped streaming, the file I streamed to was 15 minutes in length and viewable. Is there a way to stream to a file while capping it somehow, so that it is shown live and then what has already been displayed is deleting somehow in the original? For example, if I wanted to stream 24/7, I obviously could not continue recording to one file indefinitely as it would become ridiculously large over time.

    Sorry to bother with this question but I got the vibe you might know.

  25. yah this may seem like a stupid question, but where do i put this code? i tryed typing it in to the windows cmd but it said vlc was not a recognized command and i cant find anything in vlc, so, what do i do?

  26. Oarion,

    I can't really visualize your setup. Are you using a workstation with VLC running on it to create a stream of that machines desktop to send to a server? What is the server running? VLC? Apple Quicktime Server?

    If you're using VLC on the server as well, I do know that it has a file chunking facility in there. I don't know off-hand what the switch for it is, but if you look online for "saving video file chunks in vlc" you should get something.

    Let me know….

    TTYL
    Many

  27. Hi Austin,

    Good question….I forgot to mention it. You are using the right command (cmd window), but you need to first cd (change directory) to the folder where you installed vlc in. That under windows (normally) is c:\program files\vlc . So you would issue "cd c:\program files\vlc" as the first command (without the quotes). That puts you inside the folder where vlc (the executable file that was not found in your first attempt) is located.

    Hope this helps….

    TTYL
    Many

  28. Many,

    Thanks for the response! I am not sure what file chunking is, I have tried to search around but am a little confused.

    I am actually streaming a linux box's desktop via vlc to a video file on that machine which is synced in a DropBox account, so it's synced to an online server. For testing purposes I am doing this all on one machine, but what I would then like to do is log into DropBox on a second (linux) machine and view the stream live, either in VLC or something else.

    I don't have external or fixed IP addresses on my machines because the Internet in my appartment is part of a college residence hall network, so my work around to stream from one machine to another has been through the free DropBox account, which gives me 2 gigabytes of personal private storage space.

    So far this has WORKED (steady with about a one minute lag) but I would like to know if there is a way to keep the output file from getting too large (not just talking about compression, I would like to know if there is a way to cap it somehow. I am only concerned about "live" viewing and don't need to keep everything), as I would like to not have to worry about over filling up my DropBox account so I can actually use it for normal purposes.

  29. Hi Oarion,

    Hmmm….okay…..have you tried to use a Unix pipe? I tried it on my dropbox account and it seemed to work atleast from OSX. Use (from commandline) the mkfifo command to create this "special file". Then you can start writing to it and see if you can receive the video on the other machine……hopefully this works. Let me know how it turns out.

    TTYL
    Many

  30. sorry, can you do a step- by- step for just simply using ONE computer + vlc to get a video desktop? Trust me ive tried everywhere Please help!!!

  31. Hi Andrew,

    Not sure what you mean by ONE computer….That kinda defeats the purpose….no? Stream the desktop of a computer to itself?

    TTYL
    Many

  32. Really nice post. I just stumbled upon a person’s web site in addition to planned to say that I’ve got actually enjoyed surfing around your website content. In any case I am subscribing to your rss feed so i do hope you create just as before very soon!

Leave a Reply