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(); }
movie.setTracks(new LinkedList<Track>());
movie.setTracks(new LinkedList<Track>());
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String start = request.getParameter("start"); List<Track> tracks = movie.getTracks(); movie.setTracks(new LinkedList<Track>());
private void writeMp4(List<Track> tracks) throws IOException { Movie m = new Movie(); m.setTracks(tracks); Mp4Builder mp4Builder = getFileBuilder(m); Container isoFile = mp4Builder.build(m); System.out.print("Writing t "); WritableByteChannel wbc = new FileOutputStream(outputFile).getChannel(); try { isoFile.writeContainer(wbc); } finally { wbc.close(); } System.out.println("Done."); }
File fileOne = new File(mediaStorageDir.getPath() + File.separator +"theNameOfMyFirstVideo.mp4"); File fileTwo = new File(mediaStorageDir.getPath() + File.separator +"theNameOfMySecondVideo.mp4"); FileInputStream fisOne = new FileInputStream(fileOne); FileInputStream fisTwo = new FileInputStream(fileTwo); Movie video = MovieCreator.build(Channels.newChannel(fisOne)); Movie videoTwo = MovieCreator.build(Channels.newChannel(fisTwo)); List<Track> videoTracks = video.getTracks(); Track testOneVideoTrack = videoTracks.get(0); video.setTracks(new LinkedList<Track>()); List<Track> videoTwoTracks = videoTwo.getTracks(); Track testTwoVideoTrack = videoTwoTracks.get(0); video.addTrack(new AppendTrack(testTwoVideoTrack,testOneVideoTrack)); int counterFileNumber = 0; while(new File(mediaStorageDir.getPath() + File.separator +"VID_TO_TUTFIN_"+ counterFileNumber + ".mp4").exists()){ counterFileNumber++; } IsoFile out = new DefaultMp4Builder().build(video); String outputFileNameString = mediaStorageDir.getPath() + File.separator +"VID_TO_TUTFIN_"+ counterFileNumber + ".mp4"; FileOutputStream fos = new FileOutputStream(new File(String.format(outputFileNameString))); out.getBox(fos.getChannel()); fos.close();
MovieCreator mc = new MovieCreator(); Movie video = mc.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/count-video.mp4"))); Movie audio = mc.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/count-english-audio.mp4"))); List<Track> videoTracks = video.getTracks(); video.setTracks(new LinkedList<Track>()); List<Track> audioTracks = audio.getTracks(); for (Track videoTrack : videoTracks) { video.addTrack(new AppendTrack(videoTrack, videoTrack)); } for (Track audioTrack : audioTracks) { video.addTrack(new AppendTrack(audioTrack, audioTrack)); } IsoFile out = new DefaultMp4Builder().build(video); FileOutputStream fos = new FileOutputStream(new File(String.format("output.mp4"))); out.getBox(fos.getChannel()); fos.close();
MovieCreator mc = new MovieCreator(); Movie video = mc.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/count-video.mp4"))); Movie audio = mc.build(Channels.newChannel(AppendExample.class.getResourceAsStream("/count-english-audio.mp4"))); List videoTracks = video.getTracks(); video.setTracks(new LinkedList()); List audioTracks = audio.getTracks(); for(Track videoTrack:videoTracks){ video.addTrack(new AppendTrack(videoTrack, videoTrack)); } for(Track audioTrack:audioTracks){ video.addTrack(new AppendTrack(audioTrack, audioTrack)); } IsoFile out = new DefaultMp4Builder().build(video); FileOutputStream fos = new FileOutputStream(new File(String.format("output.mp4"))); out.getBox(fos.getChannel()); fos.close();
nuMovie.setTracks(tracks);
Movie movie = MovieCreator.build(VideoPath); List<Track> tracks = movie.getTracks(); movie.setTracks(new LinkedList<Track>());
Movie movie = MovieCreator.build(src.getAbsolutePath()); List<Track> tracks = movie.getTracks(); movie.setTracks(new LinkedList<Track>()); double startTime = startMs/1000; double endTime = endMs/1000;
movie.setTracks(new LinkedList<Track>());
movie.setTracks(new LinkedList<Track>()); double startTime = startMs / 1000; double endTime = endMs / 1000;