FileDocCategorySizeDatePackage
MuxMp4SourcesExample.javaAPI Docmp4parser 1.0-RC-172489Wed Dec 19 20:10:38 GMT 2012com.googlecode.mp4parser

MuxMp4SourcesExample

public class MuxMp4SourcesExample extends Object
Muxes 2 audio tracks with a video track.

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


        String audioDeutsch = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-deutsch-audio.mp4";
        String audioEnglish = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-english-audio.mp4";
        String video = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-video.mp4";


        Movie countVideo = MovieCreator.build(new FileInputStream(video).getChannel());
        Movie countAudioDeutsch = MovieCreator.build(new FileInputStream(audioDeutsch).getChannel());
        Movie countAudioEnglish = MovieCreator.build(new FileInputStream(audioEnglish).getChannel());

        Track audioTrackDeutsch = countAudioDeutsch.getTracks().get(0);
        audioTrackDeutsch.getTrackMetaData().setLanguage("deu");
        Track audioTrackEnglish = countAudioEnglish.getTracks().get(0);
        audioTrackEnglish.getTrackMetaData().setLanguage("eng");

        countVideo.addTrack(audioTrackDeutsch);
        countVideo.addTrack(audioTrackEnglish);

        {
            IsoFile out = new DefaultMp4Builder().build(countVideo);
            FileOutputStream fos = new FileOutputStream(new File("output.mp4"));
            out.getBox(fos.getChannel());
            fos.close();
        }
        {
            FragmentedMp4Builder fragmentedMp4Builder = new FragmentedMp4Builder();
            fragmentedMp4Builder.setIntersectionFinder(new SyncSampleIntersectFinderImpl());
            IsoFile out = fragmentedMp4Builder.build(countVideo);
            FileOutputStream fos = new FileOutputStream(new File("output-frag.mp4"));
            out.getBox(fos.getChannel());
            fos.close();
        }