-
Notifications
You must be signed in to change notification settings - Fork 330
Parsing SCTE35 tag from playlist #40
Conversation
Hey @grafov any plan on merging this code ? Anything more needed from my end ? |
We'd also like to see this get merged, but a few personal queries/comments:
|
sure @bradleyfalzon I will do whatever i can from my end |
Sorry for delays too busy. I will merge it after small check ASAP. |
I'm also thinking that these SCTE tags should be added to it's own struct, such as:
This way it's easier to add extra tags in the future, and contains all SCTE in the same way it's done for Key and Map. This is a slightly more substantial change to the code, but I think it's straight forward to do and makes sense in relation to how other optional tags are handled. Thoughts? |
@bradleyfalzon makes perfect sense. Will do these changes in an hour or two and update the pull request |
Hey guys @bradleyfalzon @grafov done withe changes as discussed above |
for _, sep := range scteData { | ||
SCTEData := strings.Split(line[12:], ",") | ||
state.scte = new(SCTE) | ||
for _, sep := range SCTEData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this for loop use the decodeParamsLine
, similar to the EXT-X-KEY on line 396? Or is there a quoting issue? As I think this loop expects an example line to look like #EXT-SCTE35: CUE=SOMEDATA,ID=SOMEID,TIME=3.142
, whereas the example in http://www.scte.org/documents/pdf/standards/SCTE%2067%202014.pdf shows the fields should be quoted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, i will look up that function after some time and make use of it/ write something similar for our purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies, the for loop does correctly handle quotes for strings, and no quotes for float, which is expected - sorry for the confusion. But I think decodeParamsLine
may still be suitable, such as:
case !state.tagSCTE35 && strings.HasPrefix(line, "#EXT-SCTE35:"):
state.tagSCTE35 = true
state.listType = MEDIA
state.scte = new(SCTE)
for k, v := range decodeParamsLine(line[12:]) {
switch k {
case "CUE":
state.scte.Cue = v
case "ID":
state.scte.ID = v
case "TIME":
state.scte.Time, _ = strconv.ParseFloat(v, 64)
}
}
Which handles a sample playlist like this nicely:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:00001
#EXTINF:9.9,
http://server-host/path/file44.ts
#EXTINF:4.2,
http://server-host/path/file45.ts
#EXT-SCTE35: CUE="/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA=="
#EXTINF:10
stream_med_00001.ts
#EXTINF:4,
stream_med_00002.ts
#EXT-SCTE35: CUE="/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==", ID="someidentifier1", TIME=3.142
#EXTINF:6,
stream_med_00003.ts
#EXTINF:4,
stream_med_00004.ts
#EXT-SCTE35: CUE="/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==", ID="someidentifier2", TIME="3.142"
#EXTINF:6,
stream_med_00005.ts
#EXTINF:6,
stream_med_00006.ts
#EXT-SCTE35:CUE="/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==",ID="someidentifier3",TIME="3.142"
#EXTINF:6,
stream_med_00007.ts
#EXT-X-ENDLIST
Thanks again for these minor changes, the PR is useful and we are thankful for it, feel free to add yourself to the AUTHORS file too, if not, we'll add it at a later stage.
New PR looks good, I've added a comment re decoding. I'd love to see a good unit test for this as well for the reader and writer changes as I think it would provide a lot of value to see how this is expected to be used. Perhaps adding an example in sample-playlists folder (just a couple EXT-SCTE35 tags with just CUE tag and one with CUE+ID+TIME) and adding a test to reader_test.go and writer_test.go to verify it's behaving correctly. I can assist an example once you clarify the decoding comment (so I know that quoting should be required). |
Hey @bradleyfalzon done with the changes :) |
Brilliant, looks good will test and merge hopefully within the next 12 hours. I didn't notice before, but it looks like this is just reader methods, not writer, I can add them in at a later stage, something like the following (can you double check my suggestion) but with tests. Did you have plans to add that in the future, if not, I can.
|
@bradleyfalzon Yeah, please go ahead and add the writer code. I just didn't go much through the writer methods, but your code gave me a good idea. Just 1 suggestion, i feel you should use precision as -1 instead of 3, which would help to reform the float64 variable Time back Refer : https://golang.org/pkg/strconv/#FormatFloat I can create another PR for writer test cases later |
Parsing SCTE35 tag from playlist
@vishal24tuniki Did you check out the updated HLS draft RFC's SCTE35 support? https://www.ietf.org/rfcdiff?url1=draft-pantos-http-live-streaming-18&url2=draft-pantos-http-live-streaming-19 |
@bradleyfalzon interesting ! Will go through them in next couple of days |
Parsing SCTE35 tag from playlist
Adding feature as per SCTE standards
Ref : http://www.scte.org/documents/pdf/standards/SCTE%2067%202014.pdf 12.1.6.1 HLS Cue Tags