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

How to detect live streaming vs VOD in ExoPlayer #2668

Closed
shailesh-fusionitechnology opened this issue Apr 11, 2017 · 7 comments
Closed

How to detect live streaming vs VOD in ExoPlayer #2668

shailesh-fusionitechnology opened this issue Apr 11, 2017 · 7 comments
Assignees

Comments

@shailesh-fusionitechnology

Is there is any method available right now for distinguish between live streaming and VOD?

I have already seen track #2099 that is posted on dated Nov 23, 2016. On that time there is no such method available for distinguish between live streaming and VOD.

Since the above post is almost 5 months old. Now I want to conform that Is there is any method available right now for distinguish between live streaming and VOD?

I have also try by get duration of video but unable to find distinguish between Live Streaming and VOD?

@ojw28
Copy link
Contributor

ojw28 commented Apr 11, 2017

As described in the issue you reference, you can use isCurrentWindowDynamic for this.

@ojw28 ojw28 added the question label Apr 11, 2017
@Teviz
Copy link

Teviz commented Apr 25, 2017

@ojw28
I found that method #isCurrentWindowDynamic sometimes is not accurate.
When play FLV media, the method isCurrentWindowDynamic returns false because it's a single file media, but it may be live streaming.

Presently I check the result of isCurrentWindowDynamic && isCurrentWindowSeekable to distinguish between live streaming and VOD. I wonder is there a better way to do that too.

@ojw28
Copy link
Contributor

ojw28 commented Apr 25, 2017

Yes, that's a good point. The method described will only work for DASH, HLS and SmoothStreaming.

You can get on-demand (i.e. non-live) content that's not seekable. You're probably better off looking at the duration (ExoPlayer.getDuration). If it's unknown, that's a pretty good sign that you're dealing with a live stream. So you could try OR'ing this approach with the one based on the window being dynamic.

By the way, did you mean || instead of && in your comment? I don't think && is what you'd want?

@Teviz
Copy link

Teviz commented Apr 25, 2017

Oh yes, sorry for that, I made two mistakes. I was intent to say isCurrentWindowDynamic || !isCurrentWindowSeekable.

So the recommended way is to use isCurrentWindowDynamic || getDuration == C.TIME_UNSET to solve the problem. Thanks you for that.
By the way, in which situation the on-demand content is not seekable?

@ojw28
Copy link
Contributor

ojw28 commented Apr 25, 2017

That approach seems like it would get it right in the vast majority of cases, yes. Give it a try and let us know.

It's actually quite difficult to determine whether a stream is live in the completely general case. If you compared an on-demand stream that doesn't define its duration or seek information and is served from a server that doesn't tell you the content length, that would be impossible to distinguish from a genuine live stream. Admittedly that combination is quite far fetched.

On-demand media isn't seekable in the case that it doesn't define any seek information (e.g. in the media container) to enable the player to perform an efficient seek. Raw MPEG-TS streams are a good example of this (HLS is seekable because the media playlist effectively provides seek information at a higher level).

@ojw28
Copy link
Contributor

ojw28 commented Apr 25, 2017

Given there are lots of properties you could look at to try and determine whether a stream is live, we should probably add an isLive method and implement our best-attempt logic there (which can be updated over time, if needed). Marking as an enhancement.

@ojw28
Copy link
Contributor

ojw28 commented May 15, 2019

@tonihei - Reassigning because this touches on Timeline and Player. It's probably preferable to plumb isLive through Timeline.Window and having Player.isCurrentWindowLive, so that sources can potentially use additional information to control how isLive gets set. For example ProgressiveMediaSource should probably set to isLive=false if the response has a known content length, even if the duration still cannot be determined.

It might be nice to fix this so that we can remove this not exactly accurate troubleshooting entry, if it's relatively straightforward. Although perhaps it fits better into the bigger playlist simplification work.

ojw28 pushed a commit that referenced this issue Oct 2, 2019
This flag is currently merged into Window.isDynamic, which isn't always true
because
1. A window can be dynamic for other reasons (e.g. when the duration is still
missing).
2. A live stream can be become non-dynamic when it ends.

Issue:#2668
Issue:#5973
PiperOrigin-RevId: 271999378
@ojw28 ojw28 closed this as completed Oct 2, 2019
ojw28 pushed a commit that referenced this issue Oct 15, 2019
@google google locked and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants