Comments (3)
@grafov, what's your thoughts on this?
It appears to create a NewMediaPlaylist for VoD, we need to set the window size to 0 and the capacity to some large number, then call the Decode or DecodeFrom on this newly created playlist.
Such as (where media.m3u8
is a copy of sample-playlists/wowza-vod-chunklist.m3u8
):
f, err := os.Open("media.m3u8")
if err != nil {
fmt.Println(err)
}
p, err := m3u8.NewMediaPlaylist(0, 1000)
if err != nil {
fmt.Println(err)
}
err = p.DecodeFrom(bufio.NewReader(f), false)
if err != nil {
fmt.Println(err)
}
fmt.Printf("Playlist object: %+v\n", p)
If someone follows the above steps, then the playlist will be empty but PR #38 should fix the problem.
But if someone uses the following method, where they might not know ahead of time whether the playlist is a Master or Media (or even if it's VoD or Live).
f, err := os.Open("media.m3u8")
if err != nil {
panic(err)
}
p, listType, err := m3u8.DecodeFrom(bufio.NewReader(f), true)
if err != nil {
panic(err)
}
switch listType {
case m3u8.MEDIA:
mediapl := p.(*m3u8.MediaPlaylist)
fmt.Printf("%+v\n", mediapl)
case m3u8.MASTER:
masterpl := p.(*m3u8.MasterPlaylist)
fmt.Printf("%+v\n", masterpl)
}
The window size appears to be set to 8 (see
Line 155 in 11af315
So, PR #38 could be merged (I'd still like to do some additional testing though), but then we should modify the Decode methods in reader.go to set the winsize
to 0 when playlist is Closed (when playlist is a VoD). For example:
--- a/reader.go
+++ b/reader.go
@@ -362,6 +362,7 @@ func decodeLineOfMediaPlaylist(p *MediaPlaylist, wv *WV, state *decodingState, l
case line == "#EXT-X-ENDLIST":
state.listType = MEDIA
p.Closed = true
+ p.winsize = 0
case strings.HasPrefix(line, "#EXT-X-VERSION:"):
state.listType = MEDIA
if _, err = fmt.Sscanf(line, "#EXT-X-VERSION:%d", &p.ver); strict && err != nil {
But because decodeLineOfMediaPlaylist
is also used when a user may have explicitly called NewMediaPlaylist(3, 1000)
the above proposal would overwrite the 3 to 0 - which may not be what the user wanted. So perhaps a better option would be to modify the Decode function to choose a different window size once the playlist has been decoded - if it's live set winsize = 8
, if it's VoD, set to winsize = 0
. So, I'm probably leaning towards the following:
--- a/reader.go
+++ b/reader.go
@@ -194,6 +194,9 @@ func decode(buf *bytes.Buffer, strict bool) (Playlist, ListType, error) {
case MASTER:
return master, MASTER, nil
case MEDIA:
+ if media.Closed {
+ media.winsize = 0
+ }
return media, MEDIA, nil
default:
return nil, state.listType, errors.New("Can't detect playlist type")
Perhaps another PR could include options to overwrite the winsize
as the decode function does set to 8, others (probably myself) might want to change this on the fly.
from m3u8.
I've proposed exposing the winsize as well as setting it correctly on VoD in #70.
from m3u8.
This should now be resolved in #70, let me know if it's not.
from m3u8.
Related Issues (20)
- Using for range loop to MediaPlaylist.Segments would lead to nil pointer dereference HOT 2
- Fix a report card issues for passing to awesome-go list HOT 1
- M3U8 doesn't play after some time HOT 1
- EXT-X-MEDIA audio missing from VariantParams.Alternatives for master playlist decode HOT 1
- . HOT 2
- MediaPlaylist decode custom tag panic
- m3u8.DecodeFrom panics in case of blank lines in playlist
- I have a SCTE-35 parser...... HOT 1
- SCTE35 - EXT-OATCLS-SCTE35 with EXT-X-CUE-IN
- tag: #EXT-X-MEDIA attribute: CHANNELS is not recognized HOT 1
- Is this repo dead? HOT 3
- program panic when i get the url of media segments HOT 6
- safari play fail bug
- Doesn't handle "Alternatives" correctly inside a master playlist's "variants"
- program panic when I parse the media segments
- Decoding MediaPlaylist panics with error: index out of range [0] with length 0 HOT 2
- Support Tag #EXT-X-IMAGE-STREAM-INF
- set Segment key error
- Duplicate Data Resulting from Custom Tags HOT 2
- move away from RegExp
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m3u8.