pub fn subtitle_track_bylang<'a>(mp4: &'a MP4, language: &str) -> Option<&'a TrackBox> {
    let movie = mp4.movie();

    for track in &movie.tracks() {
        let mdia = track.media();
        let mdhd = mdia.media_header();
        let hdlr = mdia.handler();

        if hdlr.handler_type != b"sbtl" {
            continue;
        }
        if mdhd.language.to_string() != language {
            continue;
        }

        let stsd = mdia.media_info().sample_table().sample_description();
        match stsd.entries.iter().next() {
            Some(entry) => {
                if entry.fourcc() != b"tx3g" {
                    continue;
                }
            },
            None => continue,
        }

        return Some(*track);
    }
    None
}
/// Find the first subtitle track with a certain language.
Find the first subtitle track with a certain language.
Find the first subtitle track with a certain language .
pub fn subtitle_track_bylang<'a>(mp4: &'a MP4, language: &str) -> Option<&'a TrackBox> {
    let movie = mp4.movie();
    for track in &movie.tracks() {
        let mdia = track.media();
        let mdhd = mdia.media_header();
        let hdlr = mdia.handler();
        if hdlr.handler_type != b"sbtl" {
            continue;
        }
        if mdhd.language.to_string() != language {
            continue;
        }
        let stsd = mdia.media_info().sample_table().sample_description();
        match stsd.entries.iter().next() {
            Some(entry) => {
                if entry.fourcc() != b"tx3g" {
                    continue;
                }
            },
            None => continue,
        }
        return Some(*track);
    }
    None
}
pub fn subtitle_track_bylang < ' a > ( mp4 : & ' a MP4 , language : & str ) -> Option < & ' a TrackBox > { let movie = mp4 . movie ( ) ; for track in & movie . tracks ( ) { let mdia = track . media ( ) ; let mdhd = mdia . media_header ( ) ; let hdlr = mdia . handler ( ) ; if hdlr . handler_type != b" " { continue ; } if mdhd . language . to_string ( ) != language { continue ; } let stsd = mdia . media_info ( ) . sample_table ( ) . sample_description ( ) ; match stsd . entries . iter ( ) . next ( ) { Some ( entry ) => { if entry . fourcc ( ) != b" " { continue ; } } , None => continue , } return Some ( * track ) ; } None }
Find the first subtitle track with a certain language.
Find the first subtitle track with a certain language .
mp4
&'a MP4
language
&str
mp4
&'a MP4
language
&str