Mar 312013
 

I should stop reading Reddit when I’ve got some time to kill. It ends up eating into time I don’t have to kill.
http://www.reddit.com/r/Roku/comments/1b9uuv/stream_desktop_to_roku/c95f2nl

HTTP Live Streaming (HLS) looks pretty easy to do with VLC.
http://wiki.videolan.org/Documentation:Streaming_HowTo/Streaming_for_the_iPhone

It requires having a local web server. xampp is my favorite way to install apache on windows. You could also use IIS.
http://www.apachefriends.org/en/xampp.html

In these examples, my laptop is 192.168.5.55 and I’m using C:\xampp\htdocs\stream\ for the output folder. You will need to adjust for your environment.

If you don’t care about audio, you can use the built-in screen:// source for VLC

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy screen:// :screen-fps=10 vlc://quit --sout=#transcode{width=1280,height=720,fps=10,vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=10,ref=1},acodec=mp3,ab=96}:std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index=C:\xampp\htdocs\stream\mystream.m3u8,index-url=http://192.168.5.55/stream/mystream-########.ts},mux=ts{use-key-frames},dst=C:\xampp\htdocs\stream\mystream-########.ts}

To capture both screen and audio and video with VLC requires using dshow. Free and works:
https://github.com/rdp/screen-capture-recorder-to-video-windows-free
https://github.com/rdp/virtual-audio-capture-grabber-device

NOTE: If the screen width isn’t an exact multiple of 8, the video grabbed by dshow won’t play correctly in VLC. It will look garbled like black with diagonal lines.
For example: my laptop’s resolution is 1366×768. 1360 is a multiple of 8, but 1366 isn’t. It wasn’t until I had dshow scale the output to 1280×720 that I was able to get usable video into VLC.

Advertisement:
[HKEY_CURRENT_USER\Software\screen-capture-recorder]
"last_init_config_was"="default/from reg read config as: 768x1366 -> 720x1280 (0top 768b 0l 1366r) 10fps, dedupe? 0, millis between dedupe polling 10, m_bReReadRegistry? 0 "
"last_run_performance"=""
"capture_height"=dword:00000300
"capture_width"=dword:00000556
"start_x"=dword:00000000
"start_y"=dword:00000000
"default_max_fps"=dword:0000000a
"stretch_to_width"=dword:00000500
"stretch_to_height"=dword:000002d0
"stretch_mode_high_quality_if_1"=dword:00000000
"hwnd_to_track"=dword:00000001
"disable_aero_for_vista_plus_if_1"=dword:00000000
"track_new_x_y_coords_each_frame_if_1"=dword:00000000
"dedup_if_1"=dword:00000000
"millis_to_sleep_between_poll_for_dedupe_changes"=dword:00000000
"capture_transparent_windows_with_mouse_blink_only_non_aero_if_1"=dword:00000000

Now that I can view the dshow video without trouble, I’m ready to encode to h.264 and segment for HLS.

VLC_Desktop_Stream.bat

@echo off
rem Start Stream
del /q C:\xampp\htdocs\stream\*
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy dshow:// :dshow-vdev=screen-capture-recorder :dshow-adev=virtual-audio-capturer :dshow-aspect-ratio=16\:9 vlc://quit --sout=#transcode{width=1280,height=720,fps=10,vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=10,ref=1},acodec=mp3,ab=96}:std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index=C:\xampp\htdocs\stream\mystream.m3u8,index-url=http://192.168.5.55/stream/mystream-########.ts},mux=ts{use-key-frames},dst=C:\xampp\htdocs\stream\mystream-########.ts}

Note: Some devices honor the video stream’s stated aspect ratio, even if the video dimensions are different. My screen is 16:10, but I’m smooshing to 16:9. To make this work correctly, I had to specify the dshow aspect ratio as 16:9. No amount of fussing with it on the transcode side will fix this. It defaults to 4:3.

:dshow-aspect-ratio=16\:9

Next Step: Roku
Sign up for roku developer account and download the SDK.
http://www.roku.com/developer

The simplevideoplayer example will play HLS and is simple enough for this.
RokuSDK_v41.zip\examples\source\simplevideoplayer

Comment out the other video source lines in appMain.brs and change the URL under Apple’s HLS test stream to your local webserver.
Note: For some reason, this did not play unless I had srt = “” set.

appMain.brs

    'Apple's HLS test stream
    urls = ["http://192.168.5.55/stream/mystream.m3u8"]
    qualities = ["HD"]
    streamformat = "hls"
    title = "Apple BipBop Test Stream"
	srt = ""

  9 Responses to “HTTP Live Streaming Windows Desktop to Roku Using VLC”

  1. Hei,

    At the moment i dont have xamp web server activated but first i wanted to test this bat. I made bat file what looks like this

    @echo off
    rem Start Stream
    del /q C:\xampp\htdocs\stream\*
    “C:\Program Files\VideoLAN\VLC\vlc.exe” -I dummy dshow:// :dshow-vdev=screen-capture-recorder :dshow-adev=virtual-audio-capturer :dshow-aspect-ratio=16\:9 vlc://quit –sout=#transcode{width=1280,height=720,fps=10,vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=10,ref=1},acodec=mp3,ab=96}:std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index=C:\xampp\htdocs\stream\mystream.m3u8,index-url=http://10.111.4.1/stream/mystream-########.ts},mux=ts{use-key-frames},dst=C:\xampp\htdocs\stream\mystream-########.ts}

    If i start the bat file then nothing happens. Cmd start’s and quit. Also C:\xampp\htdocs\stream is still emty.

    What i’m doing wrong?

    Regards
    Meelis

  2. see if the link for vlc is correct

  3. Followed the steps provided and have been able to get my desktop steaming to my Roku. My only issue is when I try to play video it does not play smooth and a little choppy. Any recommendations? Really thanks for helping me solve a problem I’ve been working on for days, now if I could only fix this!

  4. Never mind… Just kept at it and figured it out. But really THANKS!

  5. Thank you so much for posting this! The virtual audio capture grabber did not work for me, but I was able to use my audio card’s built-in “stereo mix” feature instead, by enabling it (in Window’s “Sound” Control Panel) and replacing

    :dshow-adev=virtual-audio-capturer
    with
    :dshow-adev=”Stereo Mix (Realtek High Defini”

    I also had to add the mime-types for the .m3u8 and .ts file extensions to my web server’s configuration. (IIS has the good-for-security but otherwise annoying feature of giving 404 errors for file types that it doesn’t recognize.)

    It seems if you never want subtitles, you can comment-out the `print “srt = “;srt` line and the 3 lines of the if-condition that immediately follow it instead of setting the “srt” variable to an empty string. It is odd that they forgot to set that variable for their other examples so that said examples don’t work.

    @Meelis Did you try giving all users write permissions for your “stream” directory?

  6. Hey, Noob here.
    Anyone have step by step instructions after I download VLC, the screen capture recorder, audio grabber, and the Roku SDK? Not sure if I am missing something but a few of the links above are for Iphone, and I’m using a PC. Maybe I’m a dumb#&* but would love some help here,

    Thanks

  7. Hi there… great work there! Any idea what to do for the last step to get this working on a Now TV box? It’s a modified Roku LT – cant load private channels :( . Is there a way to play the stream some other way? Using Playto? Thanks

  8. Hi, i can get the stream to show up on my roku. But, the stream is garbled as in lines like this //////////// all through the screen. Sound comes through perfectly. Any ideas?

  9. You’re the best thnx very much!

    I did it with IIS – few things I had to do in case some people wanna save some time:

    1-Disable firewall on your iis machine 2- If you have a rooter remember to port forward 80 to that machine’s ip 3-Correct mime type of .ts to video/MP2T and add mime type .m3u8 as video/mpeg 4-Other thing, in my case, I couldn’t Stream it from my computer’s IP on my roku, had to use my internet ip address (that’s why I redirected port 80 to the IIS machine).

    Hope it helped a few people

    For the rest, credit to you, you’re a Genius!

 Leave a Reply

(required)

(required)

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>