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

API request - getting segments urls from the manifest #1074

Closed
odedhutzler opened this issue Oct 19, 2017 · 12 comments
Closed

API request - getting segments urls from the manifest #1074

odedhutzler opened this issue Oct 19, 2017 · 12 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@odedhutzler
Copy link

Hi,

I would like to get the list of the segments URL's that Shaka parses from the manifest.

Will this API be exposed in the future?

I mean, for example:
from this mpd:
https://cdnapisec.kaltura.com/p/1982551/sp/198255100/playManifest/entryId/0_rgc5b6a0/format/mpegdash/tags/dash/protocol/https/flavorIds/0_t02pp03c/a.mpd

getting a list of these urls:
https://vootvideo.akamaized.net/edash/p/1982551/sp/198255100/serveFlavor/entryId/0_rgc5b6a0/v/2/pv/1/flavorId/0_t,02pp03c,xzuhjd4,/forceproxy/true/name/a.mp4.urlset/fragment-1-f1-a1-x3.m4s

Also an option to chose which flavor/bandwidth etc.

Thanks,
Oded

@TheModMaker
Copy link
Contributor

Take a look at #1036. You could create a new ManifestParser that forwards to the regular DashParser and then you could look at it before you return it back to the Player. Take a look at the Manifest object and the Manifest Parser tutorial.

To choose initial streams you could create a custom AbrManager to choose the initial streams. Or you could just switch streams after starting playback using player.selectVariantTrack.

@TheModMaker TheModMaker added the type: question A question from the community label Oct 19, 2017
@joeyparrish joeyparrish added type: enhancement New feature or request and removed type: question A question from the community labels Oct 24, 2017
@joeyparrish joeyparrish added this to the v2.3.0 milestone Oct 24, 2017
@joeyparrish
Copy link
Member

We are adding a method to the player to retrieve the parsed manifest. That should simplify things for you.

joeyparrish pushed a commit that referenced this issue Nov 1, 2017
Adding an event right after the player parses the manifest, and before
initiating streaming, so that users can get the manifest information.
Adding manifest getter method in player so that customers can access
manifest information.

Closes #1043
Closes #1074
Issue #1036

Change-Id: I0016c312bacdfa86299e5df68b586f90d565cfdc
@joeyparrish
Copy link
Member

New method cherry-picked for v2.2.5.

@odedhutzler
Copy link
Author

thanks!

@odedhutzler
Copy link
Author

hey @joeyparrish, I want to use getManifest, but the variants inside the periods are lack of segments list. How can I can retrieve the segment list per a period? Do i have to create a new manifest parser plugin?

@TheModMaker
Copy link
Contributor

There isn't an exposed list of segments. This is due to the fact that in some Dash manifests there may be infinite segments. For SegmentTemplate with duration attribute, we know all segments from now to the end of the presentation (which for live is infinity). So there may not be an explicit list available.

What you can do is construct a list by using the getSegmentReference method. This takes an index and gives you the reference at that index. Most indexes start at 0, but you can use findSegmentPosition which takes a time and gives the index. You can pass in 0 for VOD or the live edge for Live content.

var list = [];
var i = stream.findSegmentPosition(0);
while (true) {
  var seg = stream.getSegmentReference(i);
  if (!seg) break;
  list.push(seg);
  i++;
}

@odedhutzler
Copy link
Author

thanks @TheModMaker ! I will get the URI with list[i].createUris();

@bennypowers
Copy link

I, too, am looking to build a list of segments: specifically all the segments which start at the times I have in a pre-determined list of times. (relative to the video's duration)

e.g. for a 5 minute video, I might want to get all the segments which start or surround each minute, on the 0th second.

After poking around the docs and the source code, I'm stumped. I'd be happy to use findSegmentPosition and getSegmentReference to build up a list of segments, but I just don't know where to find those methods, or how to make use of them.

Is the only option to proxy the parser?

@joeyparrish
Copy link
Member

No, you can use player.getManifest() to get access to our internal data structure for the parsed manifest. The findSegmentPosition() and getSegmentReference() methods are on Stream, which is inside that manifest structure. The hierarchy is manifest > period > variant > stream (audio/video). Here are the docs for the manifest structure: https://shaka-player-demo.appspot.com/docs/api/shakaExtern.html#Manifest

@joeyparrish
Copy link
Member

I'm sorry that the API for this isn't more obvious, but in some cases (DASH, SegmentTemplate+duration, live content), there is no fixed list of segments at all.

@bennypowers, @odedhutzler, can you tell us why you need a list of segments? If we understood the motivation, it might help us prioritize this idea and build a better API for you.

@bennypowers
Copy link

bennypowers commented Feb 13, 2018

In the app I'm building, the player loads along with a pre-made list of time indexes for the video. I want to be able to pre-cache those time indexes so that seeking to them is smooth and seamless. To do that, I need to fetch the relevant segment from the server before the user seeks to it.

imagine a choose-your-own adventure type app that works off of time indexes in one big video stream. You'd want to pre-load the segments for the start of each section of the video, so that the user doesn't have to sit there and buffer.

@odedhutzler
Copy link
Author

@joeyparrish I wanted to download the content, using background fetch, so i needed the segment list.
The solution @TheModMaker gave worked great for me.
Currently we will try and work with shaka offline storage, because bg fetch is not ready yet.

@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants