public static void main(String[] args) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException, URISyntaxException { Movie m = new Movie(); /* m.addTrack( new SMPTETTTrackImpl( new File("C:\\dev\\mp4parser-github\\ttml-example\\subtitle_5_0.xml"), new File("C:\\dev\\mp4parser-github\\ttml-example\\subtitle_5_1.xml"), new File("C:\\dev\\mp4parser-github\\ttml-example\\subtitle_5_2.xml")));*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document d = dbf.newDocumentBuilder().parse("C:\\dev\\mp4parser-github\\ttml-example\\subtitle_3_0.xml"); m.addTrack( new TtmlTrackImpl("some subtile", Collections.singletonList(d))); DefaultMp4Builder builder = new DefaultMp4Builder(); builder.build(m).writeContainer(new FileOutputStream("output.mp4").getChannel()); } }
public static void main(String[] args) throws URISyntaxException, ParserConfigurationException, IOException, SAXException, XPathExpressionException, TransformerException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder builder = dbf.newDocumentBuilder(); Document doc = builder.parse("C:\\dev\\mp4parser\\a.xml"); List<Document> split = TtmlSegmenter.split(doc, 60); /* for (Document document : split) { pretty(document, System.out, 4); }*/ Track t = new TtmlTrackImpl("a.xml", split); Movie m = new Movie(); m.addTrack(t); Container c = new DefaultMp4Builder().build(m); c.writeContainer(new FileOutputStream("output.mp4").getChannel()); }
public static void main(String[] args) throws IOException { String audioEnglish = RemoveSomeSamplesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-english-audio.mp4"; Movie originalMovie = MovieCreator.build(audioEnglish); Track audio = originalMovie.getTracks().get(0); Movie nuMovie = new Movie(); nuMovie.addTrack(new AppendTrack(new ClippedTrack(audio, 0, 10), new ClippedTrack(audio, 100, audio.getSamples().size()))); Container out = new DefaultMp4Builder().build(nuMovie); FileOutputStream fos = new FileOutputStream(new File("output.mp4")); out.writeContainer(fos.getChannel()); fos.close(); }
public static void main(String[] args) throws IOException { String f = Avc1ToAvc3Example.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/1365070268951.mp4"; Movie m = MovieCreator.build(new FileInputStream(f).getChannel(), new FileRandomAccessSourceImpl(new RandomAccessFile(f, "r")), "inmem"); Movie m2 = new Movie(); for (Track track : m.getTracks()) { if (track.getSampleEntries().get(0).getType().equals("avc1")) { m2.addTrack(new Avc1ToAvc3TrackImpl(track)); } else { m2.addTrack(track); } } new FragmentedMp4Builder().build(m2).writeContainer(new FileOutputStream("output.mp4").getChannel()); IsoFile i = new IsoFile("output.mp4"); for (Box box : i.getBoxes()) { System.err.println(box + "@-nooffsets"); } } }
public static void main(String[] args) throws IOException { String basePath = GetDuration.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/dash/"; Movie m = new Movie(); IsoFile baseIsoFile = new IsoFile(basePath + "redbull_100kbit_dash.mp4"); List<IsoFile> fragments = new LinkedList<IsoFile>(); for (int i = 1; i < 9; i++) { fragments.add(new IsoFile(basePath + "redbull_10sec" + i + ".m4s")); } m.addTrack(new Mp4TrackImpl(1, new IsoFile("redbull_100kbit_dash.mp4"), new FileRandomAccessSourceImpl(new RandomAccessFile("redbull_100kbit_dash.mp4", "r")), "test")); DefaultMp4Builder builder = new DefaultMp4Builder(); Container stdMp4 = builder.build(m); FileOutputStream fos = new FileOutputStream("out.mp4"); stdMp4.writeContainer(fos.getChannel()); fos.close(); } }
public static void main(String[] args) throws IOException { Movie audioMovie = MovieCreator.build("/home/sannies/scm/svn/mp4parser/silence/sample.mp4"); Movie result = new Movie(); Track audio = audioMovie.getTracks().get(0); Track silence = new SilenceTrackImpl(audio, 2000); result.addTrack(new AppendTrack(silence, audio)); Container isoFile = new DefaultMp4Builder().build(result); FileChannel fc = new RandomAccessFile(String.format("output.mp4"), "rw").getChannel(); fc.position(0); isoFile.writeContainer(fc); fc.close(); } }
public static void main(String[] args) throws IOException { String audioEnglish = RemoveSomeSamplesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-english-audio.mp4"; Movie originalMovie = MovieCreator.build(audioEnglish); Track audio = originalMovie.getTracks().get(0); Movie nuMovie = new Movie(); nuMovie.addTrack(new ReplaceSampleTrack( new ReplaceSampleTrack( new ReplaceSampleTrack( audio, 25, ByteBuffer.allocate(5)), 27, ByteBuffer.allocate(5)), 29, ByteBuffer.allocate(5))); Container out = new DefaultMp4Builder().build(nuMovie); FileOutputStream fos = new FileOutputStream(new File("output.mp4")); FileChannel fc = fos.getChannel(); out.writeContainer(fc); fos.close(); }
public static void main(String[] args) throws IOException { H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("C:\\dev\\mp4parser\\isoparser\\src\\test\\resources\\count.h264")); //AACTrackImpl aacTrack = new AACTrackImpl(new FileInputStream("/home/sannies2/Downloads/lv.aac").getChannel()); Movie m = new Movie(); m.addTrack(h264Track); //m.addTrack(aacTrack); { Container out = new DefaultMp4Builder().build(m); FileOutputStream fos = new FileOutputStream(new File("h264_output.mp4")); FileChannel fc = fos.getChannel(); out.writeContainer(fc); fos.close(); } } }
public static void main(String[] args) throws IOException { DataSource video_file = new FileDataSourceImpl("c:/dev/mp4parser2/source_video.h264"); DataSource audio_file = new FileDataSourceImpl("c:/dev/mp4parser2/source_audio.aac"); int duration = 30472; H264TrackImpl h264Track = new H264TrackImpl(video_file, "eng", 15000, 1001); //supplied duration for the attached file was AACTrackImpl aacTrack = new AACTrackImpl(audio_file); Movie movie = new Movie(); movie.addTrack(h264Track); //movie.addTrack(aacTrack); Container out = new DefaultMp4Builder().build(movie); FileOutputStream fos = new FileOutputStream(new File("c:/dev/mp4parser2/checkme.mp4")); out.writeContainer(fos.getChannel()); fos.close(); } }
public static void main(String[] args) throws IOException { Movie movie = new Movie(); Track track = new DTSTrackImpl(new FileDataSourceImpl("C:\\Users\\sannies\\Downloads\\Big_Dom_Thl_ENG_5.1_HD_Lossless_1510.dtshd")); movie.addTrack(track); DefaultMp4Builder builder = new DefaultMp4Builder(); Container container = builder.build(movie); FileOutputStream fos = new FileOutputStream("c:\\dev\\isoparser-dtshd-test.mp4"); FileChannel fc = fos.getChannel(); container.writeContainer(fc); fos.close(); } }
public static void main(String[] args) throws IOException { EC3TrackImpl track = new EC3TrackImpl(new FileDataSourceImpl("C:\\Users\\sannies\\Downloads\\audio.ac3")); Movie m = new Movie(); m.addTrack(track); DefaultMp4Builder mp4Builder = new DefaultMp4Builder(); Container isoFile = mp4Builder.build(m); FileOutputStream fos = new FileOutputStream("output.mp4"); FileChannel fc = fos.getChannel(); isoFile.writeContainer(fc); fos.close(); } }
public static void main(String[] args) throws IOException { Movie mWithVideo = MovieCreator.build("C:\\dev\\mp4parser\\examples\\src\\main\\resources\\davidappend\\v1.mp4"); Movie mWOutVideo = new Movie(); for (Track track : mWithVideo.getTracks()) { if (track.getHandler().equals("soun")) { mWOutVideo.addTrack(track); } } DefaultMp4Builder b = new DefaultMp4Builder(); Container c = b.build(mWOutVideo); c.writeContainer(new FileOutputStream("output.mp4").getChannel()); } }
public static void main(String[] args) throws IOException { Track ac3Track = new AC3TrackImpl(new FileDataSourceImpl("C:\\dev\\mp4parser\\examples\\src\\main\\resources\\count-english.ac3")); //Track ac3Track = new AC3TrackImplOld(new BufferedInputStream(new FileInputStream("C:\\dev\\mp4parser\\examples\\src\\main\\resources\\count-english.ac3"))); Movie m = new Movie(); m.addTrack(ac3Track); DefaultMp4Builder mp4Builder = new DefaultMp4Builder(); Container out = mp4Builder.build(m); FileOutputStream fos = new FileOutputStream("output.mp4"); FileChannel fc = fos.getChannel(); out.writeContainer(fc); fos.close(); } }
public static void main(String[] args) throws IOException { AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("C:\\content\\Cosmos Laundromat small.aac")); H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("C:\\content\\Cosmos Laundromat small.264")); Movie m = new Movie(); m.addTrack(aacTrack); m.addTrack(h264Track); DefaultMp4Builder mp4Builder = new DefaultMp4Builder(); Container out = mp4Builder.build(m); FileOutputStream fos = new FileOutputStream("output.mp4"); FileChannel fc = fos.getChannel(); out.writeContainer(fc); fos.close(); } }
public static void main(String[] args) throws IOException { //Movie movie = new MovieCreator().build(new RandomAccessFile("/home/sannies/suckerpunch-distantplanet_h1080p/suckerpunch-distantplanet_h1080p.mov", "r").getChannel()); Movie movie = MovieCreator.build("C:\\content\\843D111F-E839-4597-B60C-3B8114E0AA72_ABR05.mp4"); List<Track> tracks = movie.getTracks(); assert tracks.size() == 1; Track track = movie.getTracks().get(0); movie.setTracks(new LinkedList<Track>()); // remove all tracks we will create new tracks from the old double startTime = 10; double endTime = 20; long startSample = findNextSyncSample(track, startTime); long endSample = findNextSyncSample(track, endTime); movie.addTrack(new ClippedTrack(track, startSample, endSample)); Container out = new DefaultMp4Builder().build(movie); FileOutputStream fos = new FileOutputStream(String.format("output-%f-%f.mp4", startTime, endTime)); FileChannel fc = fos.getChannel(); out.writeContainer(fc); fc.close(); fos.close(); }
public static void main(String[] args) throws IOException { H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("/Users/sannies/dev/mp4parser/1532667754113.h264")); Movie m = new Movie(); m.addTrack(h264Track); Mp4Builder builder = new DefaultMp4Builder(); Container c = builder.build(m); c.writeContainer(new FileOutputStream("/Users/sannies/dev/mp4parser/1532667754113-meins.mp4").getChannel()); } }
public static void main(String[] args) throws IOException { Movie m1 = MovieCreator.build(("C:\\dev\\DRMTODAY-872\\Tears_Of_Steel_128000_eng.mp4")); Movie m2 = MovieCreator.build(("C:\\dev\\DRMTODAY-872\\Tears_Of_Steel_600000.mp4")); //WebVttTrack webVttTrack = new WebVttTrack(new , "subs", Locale.ENGLISH); TextTrackImpl textTrack = new TextTrackImpl(); textTrack.getSubs().addAll( WebVttParser.parse(new FileInputStream("C:\\dev\\DRMTODAY-872\\Tears_Of_Steel_eng.vtt"))); Movie m = new Movie(); for (Track track : m2.getTracks()) { m.addTrack(track); } for (Track track : m1.getTracks()) { m.addTrack(track); } m.addTrack(textTrack); DefaultMp4Builder builder = new DefaultMp4Builder(); builder.setFragmenter(new DefaultFragmenterImpl(2)); Container c = builder.build(m); WritableByteChannel wbc = new FileOutputStream("output.mp4").getChannel(); c.writeContainer(wbc); }
public static void main(String[] args) throws IOException { Track track = new H265TrackImpl(new FileDataSourceImpl("c:\\content\\test-UHD-HEVC_01_FMV_Med_track1.hvc")); Movie movie = new Movie(); movie.addTrack(track); DefaultMp4Builder mp4Builder = new DefaultMp4Builder(); Container c = mp4Builder.build(movie); c.writeContainer(new FileOutputStream("output.mp4").getChannel()); }
public static void main(String[] args) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException, URISyntaxException { Movie v = new Movie(); // = MovieCreator.build("C:\\dev\\DRMTODAY-872\\31245689abb7c52a3d0721447bddd6cd_Tears_Of_Steel_600000.mp4"); Track audio = new H264TrackImpl(new FileDataSourceImpl("C:\\Users\\sannies\\Downloads\\test.h264")); v.addTrack(audio); Mp4Builder defaultMp4Builder = new DefaultMp4Builder(); Container c = defaultMp4Builder.build(v); c.writeContainer(new FileOutputStream("output.mp4").getChannel()); } }
public static void main(String[] args) throws IOException { IsoFile isofile = new IsoFile("C:\\content\\bbb-small\\output_320x180-mjpeg.mp4"); ESDescriptorBox esDescriptorBox = Path.getPath(isofile, "/moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stsd[0]/mp4v[0]/esds[0]"); byte[] d = new byte[esDescriptorBox.getData().rewind().remaining()]; esDescriptorBox.getData().get(d); System.err.println(Hex.encodeHex(d)); Movie mRef = MovieCreator.build("C:\\content\\bbb-small\\output_320x180_150.mp4"); Track refTrack = mRef.getTracks().get(0); File baseDir = new File("C:\\content\\bbb-small"); File[] iFrameJpegs = baseDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jpg"); } }); Arrays.sort(iFrameJpegs); Movie mRes = new Movie(); mRes.addTrack(new OneJpegPerIframe("iframes", iFrameJpegs, refTrack)); new DefaultMp4Builder().build(mRes).writeContainer(new FileOutputStream("output-mjpeg.mp4").getChannel()); } }