Watch twitch.tv/justin.tv/own3d.tv streams in VLC

The increase in popularity of user-generated streams, driven by Starcraft II and several of the games in the moba genre, has given rise to an enormous expansion of streaming providers such as Twitch.tv and Own3d.tv. Unfortunately, to enjoy these streams, you’re usually tied to a browser window and the flash player to enjoy these streams. You can name the upsides of this solution all you want, but the obvious downsides remain:

  • doesn’t work on systems that don’t have the flash player (like those heinous i-devices)
  • introduces horrible usability, e.g.:
    • no volume adjusting by scroll wheel or multimedia keys
    • no clicking onto the video to bring focus to it (without it redirecting you to some page)
    • no small window-borders, instead you have the cluttered browser ui where it’s completely unnecessary
    • no way of viewing the actual resolution of the stream’s video data
  • high cpu load when VLC can playback h264 using the GPU’s video decoding unit to do this more efficiently

… i guess you catch my drift.

Sadly, streaming providers such as the aforementioned ones don’t provide a portable, universally usable address that users can just plug into their system’s favorite video player to playback these streams. This is where this article comes in.

Unfortunately, stream providers don’t offer streams as regular rtmp URIs and instead rely on some configuration via the respective flash video player. The obvious reason for this is, among visual customization, to provide an easy way of displaying advertisements as an overlay to the video.

Getting around this layer of abstraction can be accomplished by using rtmpdump. It provides parameters for passing along configuration parameters that are normally provided by the flash video player. Amusingly, it has an option named for justin.tv which should show that it was in part developed with accessing streams from this provider in particular in mind. You can set it to output the grabbed video/audio stream into a pipe, a construct that most operating systems support, where it can be picked up by a player that has the capability to do so.

This is where VLC [use 1.1.11 linked on the page, newer versions seem broken] comes into play, because it can do just that. It also includes a nice network streaming interface that doesn’t crap out when there is initial buffering; so far this is the best program i’ve found for this particular use.

Assembling the required configuration parameters to build a command line for rtmpdump isn’t that easy, so i’ve written a script that does it for you:

bog’s awesome stream -> vlc script

89 responses to “Watch twitch.tv/justin.tv/own3d.tv streams in VLC

    • Yes, there is rtmpdump for linux, install both, (both can be done with apt-get if you something like ubuntu or mint) and use the script, for the file paths, just put rtmpdump (for the path to rtmpdump) and vlc (for the path to vlc) use terminal and there you go

  1. Nevermind, got it to run fine in Linux. Thanks for this.

    In case any other Linux users are trying to do this:

    Fill in the channel ID field as usual (ex. “10588” without quotes for joinDOTA with Tobi Wan’s own3d.tv channel)

    For the VLC local path field just put in “vlc” without quotes

    For the RTMP local path field just put “rtmpdump” without quotes

    Remove the quotes around “”rtmpdump”” and “”vlc”” in the generated command

    Paste the command into your terminal and VLC will launch with the stream output ready to be played from the playlist

    • OK i do this and vlc does open up but its blank.
      terminal shows “[0xb01a0cf0] main stream error: cannot pre fill buffer”
      and the error with different addresses goes on .
      Any idea whats going wrong

  2. it buffers a lot 😦 i’m using 1.1.11 as well. i can get owned streams working on vlc without the buffering/lagging/artifacting but for some reason twitch streams keep buffering/lagging/artifacting for me.

  3. Hello, very good job but unable to make it run as standalone (with source provided), display is :

    0) { // handle own3d.tv requests if($_POST[‘hoster’] == “own3d”) { $own3dtv = file_get_contents(“http://www.own3d.tv/livecfg/”.$_POST[‘channelname’]); if(preg_match(‘@@sim’, $own3dtv, $matches) && preg_match_all(‘@@sim’, $matches[2], $itemmatches)) { for($i=0; $iconnect, “live-cdn”)) $justinlegacyparams = ‘-j “‘.str_replace(‘”‘, ‘\”‘, $val->token).'” ‘; else $justinlegacyparams = “”; $result[$val->type] = ‘-r “‘.$val->connect.’/’.$val->play.'” ‘.$justinlegacyparams.’–swfVfy “‘.$swfaddr.'” -v -o -‘; } } die(json_encode($result)); } else { // HIDEME } // HIDEME $src = file_get_contents(basename($_SERVER[‘SCRIPT_FILENAME’])); $src = highlight_string($src, true); $stat = stat($_SERVER[‘SCRIPT_FILENAME’]); $lastchange = date(“d.m.Y H:i:s”, $stat[‘mtime’]); echo <<

  4. Thx mate! Finally i can watch stream on the 2nd monitor and play on the first. I have a weak CPU so that was impossible with flash.

    • Here is the code I am using:
      “C:\temp\rtmp\rtmpdump.exe” -r “rtmp://199.9.254.240/app/jtv_znHC0Yf_TJItYhoC” -j “” –swfVfy “http://www-cdn.jtvnw.net/widgets/live_embed_player.r8e3515ea4da2372c5c55a1be618c46f2075fc862.swf?channel=rugga_gamer&referer=&userAgent=&channel=rugga_gamer” -v -o – | “C:\Program Files (x86)\VideoLAN\VLC\vlc.exe” –

  5. Well keep up the good work. The stream I use is only pw protected some of the time, so hopefully this will work then 🙂

  6. This is amazing!

    Works on gentoo linux with media-libs/rtmpdump-9999 and vlc-2.0.1.

    The development version of rtmpdump seems required at this time. rtmpdump-2.4 did not work for me because of the following error:
    /usr/bin/rtmpdump: invalid option — ‘j’

    I tested with mplayer and mplayer2 and they work equally well, so if vlc is giving you trouble then try those.

    Thanks again, Julian!

    • I am getting the same “-j” issue, if it is not too much of a bother, would you be willing to tell me what development version are you using, and how could I find it? Thank you in advance

  7. Everything works fine for me, but sound. I tried 1.1.1 and 2.0, both work great for video but just no sound.

    • if that’s the same for every channel, you may have a misconfigured VLC. otherwise, you may be watching a channel where the streamer uses a free version of xsplit, which only lets you encode audio as SPEEX, which in turn vlc *i think* doesn’t support. in that case, tough luck.

  8. “You can name the upsides of this solution all you want, but the obvious downsides remain”

    Then I saw the following message on the site:
    “stop hurting esports, you motherfucker.”

    $$$ is truly the greatest upside.

  9. So say if I were to do this with Twitch.tv/ipllol would it let me watch 720p without subscribing to their channel?

  10. When I try to run the command line generated by your script for twitch streams rtmpdump says it doesn’t know what the -j option is.

  11. I’m having the same problem as AsTV. It lists the location to the rtmpdump.exe: invalid option — j
    unknown option: ?

  12. A problem, I’m watching a stream and it suddenly stops in vlc player 2.0.3
    I check the command prompt, and it always stops right when the download is complete
    Any fix to this? Thanks

  13. Any chance of getting the php source? im to much of a chobo to make my own to get the script working, in case your page goes down.

  14. I am thankful for your work and everything.. but “Stop hurting Esports, you motherfucker”. Really?
    Not only are you insulting the people that are using your script, you also nullify the entire point of it, which is watching streams in VLC, without ads. Believe it or not, you are ALWAYS costing SOMEONE ad revenues with your script.

    • I totally agree with you on the part on insulting etc. However if your reason to use the script is to get past twtich ads just get an adblocker, whole lot easier… But yes “Stop hurting Esports, you motherfucker” is very annoying, how do you get past that?

      • I do have Adblock, but it’s not about that. It’s about Twitch making my computer lag and freeze like hell while watching streams. That’s why I originally wanted to use the script.

    • Is it possible, that the message isn’t from the dev, but from twitch/owned? Otherwise I’m at a loss why he would put somthing like that in.

  15. Works perfectly. 1080p streams runs so smooth with VLC compared to Flash considering my PC is not that powerful

  16. I was wondering, where do you get the streamer’s username from? I was planning to make an application similar to yours (the only difference being it’s desktop-based and only requires a livestream url and nothing else), but I don’t really know where to get that variable from. Could you help me out by any chance?

    • hey contact me on speed_prog@hot_mail.de (remove the the two _) and I can tell you how you request the tokens and streamurls/resolutions for twitch/owned.tv streams.

  17. It seems twitch streams don’t work with rtmpdump again. Have the following in my console:

    Connecting …
    INFO: Connected…
    ERROR: Closing connection: NetStream.Play.Failed

  18. Twitch is still working.
    Btw. to everyone who has problems with newer vlc player. just don’t forward the video through standardinput and instead let rtmpdump write it to a file and open then file in vlc player. (it seems the newer versions have real problems with detecting codecs out of stdin)

  19. You sir, are a gentleman and a scholar. Thank you for this awesome script.
    There is a “-j” parameter that is not recognized under Windows XP. Deleting it seems to fix the problem.

  20. Pingback: Serviio plugin: Twitch.tv « julian's techblog

  21. Its possible to add azubu.tv ?

    Now that own3d is down, we need this new option.

    Thanks for the work 😉

    • perhaps, but i had a quick look and couldn’t find a way.

      also, there are like 3 streamers on there, so adding support in the script is not really interesting to me.

      you can however in chrome open up a streamer’s page, right click anywhere on the page, go to “inspect element”, then go to the network tab, sort for size, look for the largest file (which should be on a server named “azubulivehd-lh.akamaihd.net”), right-click on it and copy the link. you can then paste that link into VLC’s open network location window and you’ll see the stream.

  22. And again I get
    Connecting …
    INFO: Connected…
    ERROR: Closing connection: NetStream.Play.Failed

    when I try to dump a stream. It looks like your script does not fetch the right command line parameters sometimes, or it’s an issue with twitch servers, because everything might work the next day.

    PS
    I’m trying to watch http://www.twitch.tv/pubepoh that channel ang get the following command line (I’m using the latest rtmpdump from your script page).
    “C:\\rtmp\\rtmpdump.exe” -r “rtmp://199.9.254.240/app/jtv_7WVi_60NJpiWkE0q” -j “709ba0077d9c1db89a1eb74035f10c0d4ea357d9:{\”swfDomains\”: [\”justin.tv\”, \”jtvx.com\”, \”xarth.com\”, \”twitchtv.com\”, \”twitch.tv\”, \”newjtv.com\”, \”jtvnw.net\”, \”wdtinc.com\”, \”imapweather.com\”, \”facebook.com\”, \”starcrafting.com\”], \”streamName\”: \”jtv_7WVi_60NJpiWkE0q\”, \”expiration\”: 1367568419.822196, \”geo_ip\”: \”87.151.205.64\”, \”server\”: \”video12-2.fra01\”}” –swfVfy “http://www-cdn.jtvnw.net/widgets/live_embed_player.r7275d51f02c750bd6469da8c006d12a855f01270.swf?channel=pubepoh&referer=&userAgent=&channel=pubepoh” -v -o – | “C:\\Program Files\\VideoLAN\\VLC\\vlc.exe” – –play-and-exit

    • the script is working all right, it is just that twitch servers are really unstable. It simply means the data fetched is already out of date.

  23. The last two days I’ve been getting the following error:

    ERROR: HandleCtrl: Ignoring SWFVerification request, use –swfVfy!

    I fixed this by trying my hand at Wireshark. I noticed two things you can do:

    1.) For the –swfVfy part, you can use http://www.twitch.tv for the base URL.
    2.) I think Twitch took notice of the user agents the cmd commands are generated with and connect to it. It connects if you remove the string following &useragent=

    Also, a couple of suggestions:

    1.) Add -f for fullscreen at the very end of the string.
    2.) Adding -m and -b switches before -o (in the rtmpdump part) seems to improve stability and reduces VLC crashes. I set “-b 10000000” and “-m” (which stands for default 120 sec timeout).

    • sorry, but i can’t reproduce this. still working fine as ever. did you (or a system update) change your rtmpdump?

      as for the suggestions… -b controls the buffer, the standard setting of which in my copy of rtmpdump is 10 hours. i don’t see how setting it to 3 hours changes anything. the timeout setting -m’s default is 30 seconds; that seems like more than enough as well. i’ve not encountered serious problems with twitch in a while, so i can’t reproduce chokiness or similar things, and before i just add these unilaterally for everyone, i’d prefer to hear some more voices that confirm that using these switches actually helps as compared to not using them.

      • Oh crap, you’re right, I was using the -b switch wrongly (I thought it required bytes). Will try to fiddle around more with that before I make any more “smart” suggestions. 🙂

        As for the error, I don’t know how your script works. Does it take the user’s user agent and appends that? If that’s the case, is there a possibility that Twitch banned my (usual) user agent in some weird way? It can’t be a standard ban because streaming via Flash Player works fine.

  24. Pingback: Twitch Mobile Stream API | julian's techblog

  25. Hey guys,
    since I switched to a new Mac I can get the stream to work anymore… I installed everything the same way. However, when I paste the command line in the Terminal Window and I want to srat the stream in VLC I get the error:
    [0x1002541f8] main stream error: cannot pre fill buffer

    Does anybody have a solution to this problem?
    Much appreciacted!

      • Thanks for your reply!

        What do you mean with the “I vlc” part?
        The last part of the ouput from your command line where it addresses VLC? If I delete that, nothing happens.
        Sorry if I am behaving dumb right now….

      • Nevermind, it’s working now. Deleted all files related to rtmpdump and install again. Now it works perfect!
        Thanks for your work and support!

  26. Pingback: How to get video stream from rtmp server to Android? | Android Questions

  27. What happened to the link?
    It appears to be offline. Could you fix it please?
    Hope to enjoy those streams in VLC again 🙂

Leave a reply to SpeedProg Cancel reply