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

strange behaviour between media playlist and its segments unknown tags #55

Open
clitic opened this issue Sep 14, 2022 · 11 comments · May be fixed by #59
Open

strange behaviour between media playlist and its segments unknown tags #55

clitic opened this issue Sep 14, 2022 · 11 comments · May be fixed by #59

Comments

@clitic
Copy link
Contributor

clitic commented Sep 14, 2022

const PLAYLIST: &str = r"#EXTM3U
#EXT-PLAYLIST-UNKNOWN-TAG
#EXT-X-TARGETDURATION:10
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-1.ts
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-2.ts
#EXT-X-ENDLIST
";

fn main() {
    let mut playlist = m3u8_rs::parse_media_playlist_res(PLAYLIST.as_bytes()).unwrap();

    println!(
        "{:#?}\n{:-^40}\n{:#?}\n{:-^40}",
        playlist.unknown_tags, "-", playlist.segments[0].unknown_tags, "-"
    );

    // FORCE PLAYLIST UNKNOWN TAG
    playlist.segments[0].unknown_tags.remove(0);
    playlist.unknown_tags.push(m3u8_rs::ExtTag {
        tag: "PLAYLIST-UNKNOWN-TAG".to_owned(),
        rest: None,
    });
    playlist.write_to(&mut std::io::stdout()).unwrap();
}
[]
----------------------------------------
[
    ExtTag {
        tag: "PLAYLIST-UNKNOWN-TAG",
        rest: None,
    },
    ExtTag {
        tag: "SEGMENT-UNKNOWN-TAG",
        rest: None,
    },
]
----------------------------------------
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-1.ts
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-2.ts
#EXT-X-ENDLIST
@clitic clitic changed the title strange behaviour b/w media playlist and its segments unknown tags strange behaviour between media playlist and its segments unknown tags Sep 14, 2022
sdroege added a commit to sdroege/m3u8-rs that referenced this issue Oct 28, 2022
@sdroege sdroege linked a pull request Oct 28, 2022 that will close this issue
@sdroege
Copy link
Collaborator

sdroege commented Oct 28, 2022

See #59

@clitic
Copy link
Contributor Author

clitic commented Oct 28, 2022

@sdroege I think PR only fixes write_to method. What about parsing unknown media playlist unknown tags into unknown_tags field ?

@sdroege
Copy link
Collaborator

sdroege commented Oct 28, 2022

Indeed. The problem here is that everything that is not a known media playlist tag ends up in a media segment as there's no clear indication in HLS between what is the media playlist "header" and where the media segments are starting.

This looks like it could be improved a bit though. Your first #EXT-SEGMENT-UNKNOWN-TAG could be either part of the "header" or part of the first segment, but the other unknown tags are clear.

What we could probably do here is to consider everything part of the "header" until the first known media segment tag is found. In that case your first #EXT-SEGMENT-UNKNOWN-TAG would not be part of the media segment though.

What do you think?

@clitic
Copy link
Contributor Author

clitic commented Oct 28, 2022

Thanks for explaining me so well. I understood that we can't parse #EXT-PLAYLIST-UNKNOWN-TAG because it can be a potential segment unknown tag. Maybe we can specify media playlist unknown tags after the last segment similar to #EXT-X-ENDLIST tag.

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-1.ts
#EXT-SEGMENT-UNKNOWN-TAG
#EXTINF:10,
seg-2.ts
#EXT-PLAYLIST-UNKNOWN-TAG
#EXT-X-ENDLIST

@sdroege
Copy link
Collaborator

sdroege commented Oct 28, 2022

I would consider everything part of the playlist until the first known media segment tag, and everything after the last media segment URL/filename also as part of the playlist. Everything in between would be for the next segment.

@clitic
Copy link
Contributor Author

clitic commented Oct 28, 2022

It would be the best solution to this problem. If someone wants to check unknown_tags for first segment, then it can be inferred from playlist unknown_tags.

@sdroege
Copy link
Collaborator

sdroege commented Oct 28, 2022

Or they would have to be after some other known media segment tag, e.g. between the extinf and segment URL/filename

@clitic
Copy link
Contributor Author

clitic commented Oct 28, 2022

I have never seen a playlist using media unknown tags in between segments. Everything between the extinf and segment URL/filename should be considered as segment unknown tags.

@sdroege
Copy link
Collaborator

sdroege commented Oct 28, 2022

That's what I'm saying, yes. Sorry if I wasn't clear :)

@vagetman
Copy link
Contributor

hey @sdroege are you still working on this?

@sdroege
Copy link
Collaborator

sdroege commented Jan 19, 2023

Not right now, please feel free to take this over.

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

Successfully merging a pull request may close this issue.

3 participants