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 585 forks source link

Feature: twitch.tv / justin.tv archived video (VOD) support #70

Closed ph03 closed 10 years ago

ph03 commented 11 years ago

Hi!

I am wondering if it could be possible to extend the justin.tv plugin to also support archived videos that have urls like

http://nl.twitch.tv/jeffroiscool/b/299079587

The important part is the 299079587 video id. This ID can be used with the twitch.tv api to obtain the video url by, e.g.,

http://api.justin.tv/api/clip/show/299079587.xml

(see http://www.fakegaming.eu/TwitchTV/source/download.txt / http://www.fakegaming.eu/TwitchTV/download.php for a php implementation). Perhaps there is also another way to do this using some established livestreamer features. I primarily want to use it to automatically download archived videos to watch them, e.g., on my mobile phone.

chrippa commented 11 years ago

I will add support for this soon, but there is a feature missing that needs to be added first. Twitch VODs are split up into 30 min segments, so a FLV joiner needs to be added to support this.

athoik commented 11 years ago

Maybe this project helps:

Python project to join flv files with same options(normally splitted by video server) together losslessly

https://github.com/hanenoshino/FLVCopyCat

john-peterson commented 11 years ago

Alternative solution by using youtube-dl

If you're reading this thread because you want to download all parts

jabol3k commented 11 years ago

Any update on this feature ?

chrippa commented 11 years ago

Any update on this feature ?

Afraid not. Perhaps I was a bit overly optimistic in my earlier post, what I really meant was that I WANT to add it, but I don't know when, there are other things that needs to be done that are higher priority right now.

If anyone else wants to take a stab at it, here are some of my thoughts. The place to start is probably to take the timestamp adjust code from stream/hds.py and create a generic FLV concat class that you can feed a FLV tag and get a timestamp-adjusted tag back. You could then create a Stream class that reads tags from a list of Stream objects (for example a HTTPStream for each VOD segment) and processes them with previously mentioned class to get correct timestamps.

I don't know for sure if this approach will work though, the H264 timestamps may need to be adjusted aswell which would make this alot harder. Using ffmpeg might be the best option if that's the case. While that would probably limit us to the transports ffmpeg supports, that would be okay in this scenario since it's just HTTP links.

jabol3k commented 11 years ago

Your approach is to feed vlc with fake, huge file and jumping to a timestamp would trigger livestreamer to feed appropriete timestamp from file list to vlc ? I'm I understanding it correctly ? Can we just simplify this for now and do it dirty an unelegant way. The first thing that comes to mind is playlist of all files. That way You are able to curcumvent the issue with timestamps. (Leave it for better times :P).

And as to a proper issue. Can You elaborate on timestams and h264 thing? I have little to no knoledge of it, but when You talked about ffmpeg, You proposed encoding it ? Am I understanding it correctly ?

chrippa commented 11 years ago

Your approach is to feed vlc with fake, huge file and jumping to a timestamp would trigger livestreamer to feed appropriete timestamp from file list to vlc ? I'm I understanding it correctly ?

My approach is simply to basically rewrite the FLV container with correct timestamps. Most of this is already implemented in stream/hds.py, but HDS is designed to be segmented so I don't know for sure if the same approach will work on these FLV files that Twitch provides.

Can we just simplify this for now and do it dirty an unelegant way. The first thing that comes to mind is playlist of all files. That way You are able to curcumvent the issue with timestamps. (Leave it for better times :P).

Livestreamer is designed to output a raw stream of bytes to a output, such as a player or file, this is to be as compatible as possible. If we start feeding URLs to VLC or whatever, we suddenly face alot of corner cases where different players use different parameters and it would also make file output impossible.

If you want to write small script yourself that simply launches VLC with the segment URLs, the relevant API URL is http://api.justin.tv/api/broadcast/by_archive/VODID.xml. JSON is also available by changing the extension to .json.

And as to a proper issue. Can You elaborate on timestams and h264 thing? I have little to no knoledge of it, but when You talked about ffmpeg, You proposed encoding it ? Am I understanding it correctly ?

The reason we need to mess with timestamps is because if we don't, the resulting output will not be a valid FLV file. The player would play the first segment normally, but when it encounters a tag with timestamp 0 it would simply stop. So if we adjust the timestamp to continue from the last segment it should be fine, unless the H264/AAC timestamps also starts at 0, in which case we may have a problem.

I haven't looked at specifics for ffmpeg, but it might be possible to tell ffmpeg to avoid re-encoding by copying the existing data and simply rewrite the FLV container, much like the approach I was thinking of implementing in Livestreamer. But in a worst case scenario it would have to re-encode it.

ph03 commented 10 years ago

I really like the VOD support for twitch.tv. However, sometimes VODs are multiple hours long. Is it somehow possible to start streaming at a specific time? Can this be encoded by the URL like explained in

http://twitchtv.wordpress.com/2011/10/24/new-functionality-link-to-a-specific-time-in-a-vod/

or maybe as a command line parameter? I would love this functionality!

chrippa commented 10 years ago

http://twitchtv.wordpress.com/2011/10/24/new-functionality-link-to-a-specific-time-in-a-vod/

The format described in this blog post is now implemented as of 219420679ee7485124b5b4a21226066c7b2dad2b.

ph03 commented 10 years ago

Awesome, works like a charm! Thanks a lot!

just-another-random-person commented 10 years ago

All the vod links here don't work (except the first few ones): http://www.reddit.com/r/speedrun/comments/1ui4dn/agdq_vods_thread/

Probably since the params are all in hours, like: ?t=8h23m And the linked source in 2194206 only parses minutes and seconds.

ph03 commented 10 years ago

I kept converting hours to minutes and add them together, but I didn't knew that the API also supports hours.

chrippa commented 10 years ago

I added support for hours a couple of weeks ago (009360fc20fcf36ee09e9e15eb34725992c30187) and will be available in the next release.

just-another-random-person commented 10 years ago

Excellent work! Love the fast response. Thanks a lot!

Absolutely love livestreamer, infinitely better than the SLOW loading twitch player that randomly buffers for no reason.

Joopiter commented 9 years ago

Hi. It seems that "time feature" doesn't work everytime, some videos always start at the beginning. For example it doesn't work on "Past broadcast videos" here: http://www.twitch.tv/pvplive/profile/past_broadcasts

Can it be fixed or are these just broken videos?

ghost commented 9 years ago

I'm also having trouble getting the time parameter to work with "past broadcasts". Here's the video that I tried this on. It always starts at the beginning.

Joopiter commented 9 years ago

Yeah, it is still not working for me at most videos, even with latest realese.

skulblakka commented 9 years ago

Twitch uses two different systems for VODs. One is HLS based and the other one is Flash based. While you should be able to use the time parameter on the Flash based VODs it will not work on the HLS based one because Livestreamer does currently not support HLS seeking.

DerpDarako commented 9 years ago

Ok thank you for this information, because this issue is very annoying... :(

ghost commented 9 years ago

As a workaround, I've found that you can use the player-passthrough parameter with MPC-HC and then you're able to seek the video in the player. I couldn't get it to work with VLC though.

livestreamer --player-passthrough hls --player "C:\Program Files\MPC-HC\mpc-hc64.exe" www.twitch.tv/angryjoeshow/v/5158018 best
Joopiter commented 9 years ago

@aleksijuvani It is not working for me. Video still starts always at the beginning, no matter if I use VLC or MPC-HC.

BTW you didn't add time stomp to the link in your code.

ghost commented 9 years ago

Oh, it'll still start at the beginning, but I was able to seek to the middle of the video with that bar at the bottom.

this thing

The timestamp is not needed when using this method. I'm using version 1.7.8 (6fcba1b) of MPC-HC. Maybe it doesn't work on older versions? Oh, and I think the video has to use the newer HLS format for this to work.

Joopiter commented 9 years ago

Oh, right, I didn't notice. It's working, for my video at least, thanks :)

Hubro commented 9 years ago

Seeking in VODs using hls passthrough also works in VLC 2.2.0 on Linux, but there are no time stamps. The current and end time just say "00:00:00".

MaddXav commented 8 years ago

I'm getting the same issue. No timestamps on VLC, and adding the timestamp to the video url still makes it start at beginning.

famousketchup commented 8 years ago

Are there any updates on VLC timestamp issue? Player-passthrough parameter works for enabling seeking, but still no exact time