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

m3u8.DecodeFrom create playlistMedia with 1024 Segments #5

Closed
vany-egorov opened this issue Jul 25, 2014 · 5 comments · Fixed by #70
Closed

m3u8.DecodeFrom create playlistMedia with 1024 Segments #5

vany-egorov opened this issue Jul 25, 2014 · 5 comments · Fixed by #70
Assignees
Labels

Comments

@vany-egorov
Copy link

https://github.com/grafov/m3u8/blob/master/reader.go#L151

I have mediaPlaylistFile with 1203 segments (c_00000000.ts - c_00001202.ts).
But when I do: m3u8.DecodeFrom I got len(playlistMedia.Segments) == 1024!:

playlistFile, _ := os.Open(pathToMediaPlaylistFile)
defer playlistFile.Close()
playlist, listType, _ = m3u8.DecodeFrom(bufio.NewReader(playlistFile), true)
switch listType {
case m3u8.MEDIA:
    playlistMedia := playlist.(*m3u8.MediaPlaylist)
    fmt.Printf("%d\n", len(playlistMedia.Segments))
}

How can I iterate over more than 1024 segments?
How can I get total duration?
How can I get full URI slice?

@iivarih
Copy link
Contributor

iivarih commented Mar 27, 2015

This really is an issue...

Also len(Segments) == 1024 when you only have 3 segments... so in for-range loop you need to check nil values...

@matt-hensley
Copy link

MediaPlaylist.Segments is a slice. DecodeFrom auto-initializes the slice to a length of 1024: https://github.com/grafov/m3u8/blob/master/reader.go#L154

Instead use MediaPlaylist.Count method to get the current number of segments in the playlist. See https://github.com/grafov/m3u8/blob/master/writer.go#L504

@chobits
Copy link

chobits commented Nov 2, 2015

I have the same question.
There are head, tail and count private fields of MediaPlaylist structure, but only count field is exported via MediaPlaylist.Count() method.

@grafov grafov removed the ready label Feb 15, 2016
@bradleyfalzon
Copy link
Collaborator

If there's additional APIs people want, let me know and I should be able to implement. We've had similar requirements, but using .Count() methods has been fine for us (if the issue is only len(Segments)).

@bradleyfalzon
Copy link
Collaborator

#70 adds the ability for playlist to auto extend beyond 1024 segments and exposes winsize.

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

Successfully merging a pull request may close this issue.

6 participants