Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ph03 opened this issue Dec 23, 2012 · 26 comments
Closed

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

ph03 opened this issue Dec 23, 2012 · 26 comments
Assignees
Milestone

Comments

@ph03
Copy link

ph03 commented Dec 23, 2012

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
Copy link
Owner

chrippa commented Dec 23, 2012

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
Copy link
Contributor

athoik commented Jan 4, 2013

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
Copy link
Contributor

Alternative solution by using youtube-dl

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

@jabol3k
Copy link

jabol3k commented Mar 15, 2013

Any update on this feature ?

@chrippa
Copy link
Owner

chrippa commented Mar 15, 2013

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
Copy link

jabol3k commented Mar 15, 2013

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
Copy link
Owner

chrippa commented Mar 15, 2013

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
Copy link
Author

ph03 commented Dec 15, 2013

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
Copy link
Owner

chrippa commented Dec 16, 2013

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 2194206.

@ph03
Copy link
Author

ph03 commented Dec 17, 2013

Awesome, works like a charm! Thanks a lot!

@just-another-random-person

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
Copy link
Author

ph03 commented Jan 10, 2014

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

@chrippa
Copy link
Owner

chrippa commented Jan 10, 2014

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

@just-another-random-person

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
Copy link

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
Copy link

ghost commented May 18, 2015

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
Copy link

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

@skulblakka
Copy link
Contributor

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
Copy link

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

@ghost
Copy link

ghost commented May 20, 2015

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
Copy link

@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
Copy link

ghost commented May 20, 2015

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
Copy link

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

@Hubro
Copy link

Hubro commented Jun 18, 2015

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
Copy link

MaddXav commented Aug 5, 2015

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests