chrippa / livestreamer

Command-line utility that extracts streams from various services and pipes them into a video player of choice. No longer maintained, use streamlink or youtube-dl instead.
http://livestreamer.io/
BSD 2-Clause "Simplified" License
3.88k stars 580 forks source link

HLS causing VLC to drop Twitch VOD on Playback #1113

Closed X-Looper closed 9 years ago

X-Looper commented 9 years ago

Hello!

First I would like to thank chrippa for creating Livestreamer as well as those who have helped by contributing to this amazing little program, as it has made the experience when watching Livestreams much better and way more enjoyable, thank you!

Now when it comes to my issue, it's pretty much as I stated in the title. When I watch past broadcasts at Twitch.tv and I have the "player-passthrough=hls" enabled, VLC will play the past broadcast fine for roughly 30 minutes up to 1 hour and then VLC just goes black, like it dropped the connection or something, but it doesn't say anything in the command window, it just reads that last line "Starting Player...".

I would like to point out that I DO NOT have this issue if I disable the "player-passthrough=hls" option, if I do that, the Stream will play for the entire 8 - 10 hours long. But I would REALLY like to be able to use HLS for these long past broadcasts, as I prefer being able to jump and fastforward, in case I watch an hour or two in the beginning and don't want to have to re-watch those first 2 hours again.

Is there anyone here who might know if there's anything I can do to fix this myself or is this something that's completely out of my hands to do anything about?

Anyway, thanks in advance for any help regarding this!

/Regards X-Looper

skulblakka commented 9 years ago

Twitch streams are in HLS. If you use the hls-passthrough option with a hls stream, all livestreamer does is give the stream URL to the player. The player handles all the rest (like loading the stream). This is why you don't see anything in the command window, because the problem occurs in VLC.

Have you tried if the problem persists with another player?

X-Looper commented 9 years ago

Thanks for your reply, skulblakka!

Yeah, this was something I was thinking myself, that the problem might lie within VLC actually. I just thought it was weird that I had no problems when I disable the HLS Passthrough, like yeterday, I played an entire 8 - 10 hour long stream without HLS Passthrough and it played the entire thing from start to finish perfectly.

I do have MPC-HC installed as well, but I haven't tried it yet, I do prefer using VLC when watching Streams. But I'm going to see if I can try MPC-HC later today and check if that works as you suggested and I'll report back here after giving it a try.

In the meantime, is there any options or such within VLC that you or anyone else here can think of that might be the thing causing this issue with VLC when it plays the Stream through the URL in the player?

Thanks again for any help, I really appreciate it :-)

-UPDATE-

I'm running MPC-HC using "player-passthrough=hls" right now and the Twitch VOD has just passed the 1 hour mark and hasn't died on me yet, this is a good sign. I'll keep the VOD running for as long as possible, but it does seem that VLC might be the problem here, maybe it has problems with Twitch.tv VOD segments? I believe Twitch cuts VODs into 30 minute segments and maybe VLC has problems updating the URL for the next segment when using HLS?

Anyway, it looks like I'll be using MPC-HC for all my Streaming needs from now on, thanks again for all the help :-)

/Regards X-Looper

skulblakka commented 9 years ago

I believe Twitch cuts VODs into 30 minute segments

I think this was only the case with the old flash based VOD system

I'm no expert but maybe the vlc logs show something interesting when the stream blacks out. You can find the log (and change the verbosity level) under Tools->Messages (Ctrl+M).

X-Looper commented 9 years ago

It just happened in MPC-HC as well, just before it was about to hit the 2 hour mark. The video was kinda lagging, like it was dropping frames and stuttering / slowing down and then the video just stopped :-(

Do you know if MPC-HC has any log as well that I can enable / check the next time it happens? I'm no expert at these sort of things myself, it just seems like the passthrough hls thing makes the playback unstable somehow, albeit it seemed a bit more stable in MPC-HC and I'm running the VOD again to see how long it runs this time.

skulblakka, do you have these issues yourself when you play a Twitch VOD with HLS passthrough and what player are you using if I may ask?

/Regards X-Looper

skulblakka commented 9 years ago

Do you know if MPC-HC has any log as well that I can enable

I don't know. I never used MPC-HC myself and a quick google search revealed nothing.

do you have these issues yourself when you play a Twitch VOD with HLS passthrough

If the stream is loading slow (because twitch servers are busy or something else is sucking up all my bandwidth) the video and audio will sometime become temporarily asynchronous but will normally fix itself after a few seconds.

what player are you using

I am using mpv (but never had any problems using VLC)

X-Looper commented 9 years ago

Yeah, I noticed now when I tried watching the VOD again, that the video will freeze a bit and get some stuttering going, but it did fix itself. But this is also what happened before around the 2 hour mark when the video decided to die as well, kinda like a read timeout or something.

I also googled for an error log for MPC-HC right after posting and I couldn't find anything myself. I do want to ask you something though. What kind of settings do you use in Livestreamer for HLS?

These are the settings I used before: player-passthrough=hls hls-segment-threads=10 ringbuffer-size=32M

Now I changed the ringbuffer to 64M and I'm running the VOD again now and it has just passed over the 2 hour mark without dying, but I'm no expert at this so I can't say for sure if this is what might've helped with this issue.

I have also added some additional settings after browsing through the command list and added these as well:

How many attempts should be done to download each HLS segment before giving up hls-segment-attempts=10 (default 3)

HLS segment connect and read timeout hls-segment-timeout=30 (default 10)

Timeout for reading data from HLS streams hls-timeout=120 (default 60)

I have no idea if this will help with the issue at all, as I'm no expert at these sort of things and I'm kinda just testing some things out, but the idea was to try and increase the time and attempts in hopes to avoid a possible read timeout, since I feel like it might have something to do with that.

Thanks again for all your help, skulblakka :-)

-UPDATE-

Now the VOD died about 3 - 5 minutes after I posted this new message, so it survived a little longer than 2 hours this time. I will try and launch the VOD again with those new settings I added above to increase the time and attempts for timeouts and hopefully it will help.

/Regards X-Looper

skulblakka commented 9 years ago

I normally use hls-segment-threads 5 and hls-segment-attempts 5 together with 1024MB ringbuffer. As far as I know the ringbuffer is used between livestreamer and the player (livestramer writes into it and the player reads from it; allowing livestreamer to continue loading the stream while the player is not requesting it (because it is paused for example)).

However like I said before when you use hls-passthrough with a HLS stream like a Twitch VOD or livestream all livestreamer will do is give the URL to the player. This means the player will handle loading the stream and not livestreamer (this means all the network specific settings like the ones you mentioned will do nothing)

X-Looper commented 9 years ago

(this means all the network specific settings like the ones you mentioned will do nothing)

Are you absolutely sure about this? I ask because I'm watching this VOD again and about 10 minutes ago I was experiencing the video freezing and stuttering again, which was once again around the 2 hour mark. Now according to MPC-HC's Statistics, there's something called Jitter which is displayed in ms and usually hangs around 0 - 5 while the VOD is playing, that thing went haywire and jumped up to around 40 000 during this freeze / stuttering that lasted for about 15 - 20 seconds and MPC-HC also pointed out I lost over 1000 frames during this point.

It basically seemed like a huge "choke point", if that's the right term to use. However, the video didn't die this time, it actually managed to straighten itself out. This could just be some random fluke as well of course, but the VOD was "struggling" for a much longer duration and I was almost sure the video would die again, quite surprised it didn't to be honest and the VOD is still running right now as I'm typing this.

Is there any negative side-effect by having a huge ringbuffer? I might consider raising it even more after reading what you're using yourself :-)

/Regards X-Looper

ghost commented 9 years ago

I have the "player-passthrough=hls" enabled [...] I'm running MPC-HC using "player-passthrough=hls" right now [...]

It is clearly mentioned in the documentation.

--player-passthrough TYPES

A comma-delimited list of stream types to pass to the player as a URL to let it handle the transport of the stream instead.

Stream types that can be converted into a playable URL are:

        hls
        http
        rtmp

Make sure your player can handle the stream type when using this.

This means: Your problem has nothing to do with the Livestreamer application! All HTTP segments are retrieved by the video player of your choice.

X-Looper commented 9 years ago

This means: Your problem has nothing to do with the Livestreamer application!

Alright, so if Livestreamer isn't the problem, what is and how do I fix it? I'm all ears for ideas.

/Regards X-Looper

skulblakka commented 9 years ago

Is there any negative side-effect by having a huge ringbuffer?

This depends on your system. The ringbuffer needs to be stored somewhere so if you are running livestreamer on a raspberry pi or something similar I would not make it that large. On my desktop or laptop I noticed no negative side-effect.

what is and how do I fix it? I'm all ears for ideas.

You could try increasing the network timeouts and cache size of your video player

X-Looper commented 9 years ago

Thanks skulblakka. I raised mine to 256M, I've had no problems when running Livestreams normally with 32M, but I'm sure my computer could handle a lot more than that. The VOD I ran yesterday managed to run for 9 hours straight as well, so I beat my old record of 2 hours before it died, which is why I closed the issue.

So maybe the 2 first attempts when I played the VOD I just had some "bad luck" with some choke points that killed the VOD, I just thought it was funny it both happened around the 2 hour mark twice in a row. But at least MPC-HC seems to be more stable than VLC for me and while it might not be a permanent solution to my problem, I'll take any improvement over nothing at all, so many thanks again skulblakka for all your help regarding this.

I do have one last question for you though, regarding increasing network timeouts and cache size in video players. You mentioned before that you did not have this problem with VLC, are there any settings within VLC that I should check out and do some changes to, that you know might help improve stability when playing VODs?

I know there's one for cache size and I messed around with that around the time when I first learned about Livestreamer due to me having some issues with buffering. But yeah, I'm no good at these sort of things and if you could just point me in the right direction when it comes to which settings I need to adjust, I would be most grateful :-)

/Regards X-Looper

skulblakka commented 9 years ago

Using VLC I only ever used the --file-caching option (normally I used --file-caching=10000).

direwolfie commented 8 years ago

@X-Looper Sorry for being a bit off topic. But in case you are still having problems with Livestreamer - try using mpv+youtube-dl (I use this combo specifically for Twitch VODs since its the only solution I knew about and works flawlessly). You just need the 2 packages to be installed (or in the same directory in case of windows) and you can run your VOD mpv http://www.twitch.tv/stream/v/41182112 On Windows/Linux you can also use SMPlayer with mpv (on Win choose mpv during install). And enable youtube-dl in settings.

But for streams - nothing beats Livestreamer! Sorry about the bit above - the only solution that worked well enough for me. Many thanks to Livestreamer devs!