FileDocCategorySizeDatePackage
DavidAppend.javaAPI Docmp4parser 1.0-RC-172273Wed Dec 19 20:10:38 GMT 2012com.googlecode.mp4parser.stuff

DavidAppend

public class DavidAppend extends Object
Created with IntelliJ IDEA. User: sannies Date: 3/7/12 Time: 12:25 AM To change this template use File | Settings | File Templates.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


        List<Movie> movies = new LinkedList<Movie>();
        movies.add(MovieCreator.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/davidappend/v1.mp4"))));
        movies.add(MovieCreator.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/davidappend/v2.mp4"))));
        movies.add(MovieCreator.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/davidappend/v2.mp4"))));


        List<Track> videoTracks = new LinkedList<Track>();
        List<Track> audioTracks = new LinkedList<Track>();


        for (Movie m : movies) {
            for (Track track : m.getTracks()) {
                if (track.getHandler().equals("vide")) {
                    videoTracks.add(track);
                }
                if (track.getHandler().equals("soun")) {
                    audioTracks.add(track);
                }
            }
        }

        Movie concatMovie = new Movie();

        concatMovie.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
        concatMovie.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));


        IsoFile out2 = new DefaultMp4Builder().build(concatMovie);

        {
            FileChannel fc = new RandomAccessFile(String.format("output.mp4"), "rw").getChannel();
            fc.position(0);
            out2.getBox(fc);
            fc.close();
        }