pub fn media_init_section(mp4: &MP4, tracks: &[u32]) -> MP4 {
    let mut boxes = Vec::new();

    // Start with the FileType box.
    let ftyp = FileTypeBox {
        major_brand:       FourCC::new("iso5"),
        minor_version:     1,
        compatible_brands: vec![FourCC::new("avc1"), FourCC::new("mp41")],
    };
    boxes.push(MP4Box::FileTypeBox(ftyp));

    // Now the moviebox.
    let movie = mp4.movie();
    let mut movie_boxes = Vec::new();
    let mut mvex_boxes = Vec::new();
    let mut track_id = 0;
    let mut new_track_id = 0;

    for box_ in &movie.boxes {
        match box_ {
            MP4Box::MovieHeaderBox(header) => {
                // initialize MovieExtendsHeaderBox from this box.
                mvex_boxes.push(MP4Box::MovieExtendsHeaderBox(MovieExtendsHeaderBox {
                    fragment_duration: header.duration,
                }));
                // always copy this box.
                let header = header.clone();
                movie_boxes.push(MP4Box::MovieHeaderBox(header.clone()));
            },
            MP4Box::TrackBox(track) => {
                // only the selected tracks.
                track_id += 1;
                if !tracks.iter().any(|&trk| trk == track_id) {
                    continue;
                }
                new_track_id += 1;
                let track_box = fmp4_track(movie, track, new_track_id);
                movie_boxes.push(MP4Box::TrackBox(track_box));
                let trex_box = track_extends(track, new_track_id);
                mvex_boxes.push(MP4Box::TrackExtendsBox(trex_box));
            },
            _ => {},
        }
    }

    // add the MovieExtendsBox.
    movie_boxes.push(MP4Box::MovieExtendsBox(MovieExtendsBox { boxes: mvex_boxes }));

    // finally add the MovieBox to the top level boxes!
    boxes.push(MP4Box::MovieBox(MovieBox { boxes: movie_boxes }));

    MP4 {
        boxes,
        data_ref: mp4.data_ref.clone(),
        input_file: mp4.input_file.clone(),
    }
}
/// Build a Media Initialization Section for fMP4 segments.
Build a Media Initialization Section for fMP4 segments.
Build a Media Initialization Section for fMP4 segments .
pub fn media_init_section(mp4: &MP4, tracks: &[u32]) -> MP4 {
    let mut boxes = Vec::new();
    // Start with the FileType box.
    let ftyp = FileTypeBox {
        major_brand:       FourCC::new("iso5"),
        minor_version:     1,
        compatible_brands: vec![FourCC::new("avc1"), FourCC::new("mp41")],
    };
    boxes.push(MP4Box::FileTypeBox(ftyp));
    // Now the moviebox.
    let movie = mp4.movie();
    let mut movie_boxes = Vec::new();
    let mut mvex_boxes = Vec::new();
    let mut track_id = 0;
    let mut new_track_id = 0;
    for box_ in &movie.boxes {
        match box_ {
            MP4Box::MovieHeaderBox(header) => {
                // initialize MovieExtendsHeaderBox from this box.
                mvex_boxes.push(MP4Box::MovieExtendsHeaderBox(MovieExtendsHeaderBox {
                    fragment_duration: header.duration,
                }));
                // always copy this box.
                let header = header.clone();
                movie_boxes.push(MP4Box::MovieHeaderBox(header.clone()));
            },
            MP4Box::TrackBox(track) => {
                // only the selected tracks.
                track_id += 1;
                if !tracks.iter().any(|&trk| trk == track_id) {
                    continue;
                }
                new_track_id += 1;
                let track_box = fmp4_track(movie, track, new_track_id);
                movie_boxes.push(MP4Box::TrackBox(track_box));
                let trex_box = track_extends(track, new_track_id);
                mvex_boxes.push(MP4Box::TrackExtendsBox(trex_box));
            },
            _ => {},
        }
    }
    // add the MovieExtendsBox.
    movie_boxes.push(MP4Box::MovieExtendsBox(MovieExtendsBox { boxes: mvex_boxes }));
    // finally add the MovieBox to the top level boxes!
    boxes.push(MP4Box::MovieBox(MovieBox { boxes: movie_boxes }));
    MP4 {
        boxes,
        data_ref: mp4.data_ref.clone(),
        input_file: mp4.input_file.clone(),
    }
}
pub fn media_init_section ( mp4 : & MP4 , tracks : & [ u32 ] ) -> MP4 { let mut boxes = Vec :: new ( ) ; // Start with the FileType box. let ftyp = FileTypeBox { major_brand : FourCC :: new ( " " ) , minor_version : 1 , compatible_brands : vec ! [ FourCC new ( " " ) FourCC new ( " " ) ] , } ; boxes . push ( MP4Box :: FileTypeBox ( ftyp ) ) ; // Now the moviebox. let movie = mp4 . movie ( ) ; let mut movie_boxes = Vec :: new ( ) ; let mut mvex_boxes = Vec :: new ( ) ; let mut track_id = 0 ; let mut new_track_id = 0 ; for box_ in & movie . boxes { match box_ { MP4Box :: MovieHeaderBox ( header ) => { // initialize MovieExtendsHeaderBox from this box. mvex_boxes . push ( MP4Box :: MovieExtendsHeaderBox ( MovieExtendsHeaderBox { fragment_duration : header . duration , } ) ) ; // always copy this box. let header = header . clone ( ) ; movie_boxes . push ( MP4Box :: MovieHeaderBox ( header . clone ( ) ) ) ; } , MP4Box :: TrackBox ( track ) => { // only the selected tracks. track_id += 1 ; if ! tracks . iter ( ) . any ( | & trk | trk == track_id ) { continue ; } new_track_id += 1 ; let track_box = fmp4_track ( movie , track , new_track_id ) ; movie_boxes . push ( MP4Box :: TrackBox ( track_box ) ) ; let trex_box = track_extends ( track , new_track_id ) ; mvex_boxes . push ( MP4Box :: TrackExtendsBox ( trex_box ) ) ; } , _ => { } , } } // add the MovieExtendsBox. movie_boxes . push ( MP4Box :: MovieExtendsBox ( MovieExtendsBox { boxes : mvex_boxes } ) ) ; // finally add the MovieBox to the top level boxes! boxes . push ( MP4Box :: MovieBox ( MovieBox { boxes : movie_boxes } ) ) ; MP4 { boxes , data_ref : mp4 . data_ref . clone ( ) , input_file : mp4 . input_file . clone ( ) , } }
Build a Media Initialization Section for fMP4 segments.
Build a Media Initialization Section for fMP4 segments .
mp4
&MP4
tracks
&[u32]
mp4
&MP4
tracks
&[u32]