Example #1
0
  @Test
  public void testAVCClipCat() throws IOException {
    File f1 = new File("src/test/resources/AVCClipCatTest/seq_1.mp4");
    File f2 = new File("src/test/resources/AVCClipCatTest/seq_2.mp4");
    File f3 = new File("src/test/resources/AVCClipCatTest/seq_3.mp4");

    MovieBox m1 = MP4Util.parseMovie(f1);
    MovieBox m2 = MP4Util.parseMovie(f2);
    MovieBox m3 = MP4Util.parseMovie(f3);

    VirtualTrack t1 =
        new AVCClipTrack(new RealTrack(m1, m1.getVideoTrack(), new FilePool(f1, 10)), 60, 120);
    VirtualTrack t2 =
        new AVCClipTrack(new RealTrack(m2, m2.getVideoTrack(), new FilePool(f2, 10)), 60, 120);
    VirtualTrack t3 =
        new AVCClipTrack(new RealTrack(m3, m3.getVideoTrack(), new FilePool(f3, 10)), 60, 120);

    AVCConcatTrack ct = new AVCConcatTrack(t1, t2, t3);
    VirtualMovie vm = new VirtualMP4Movie(ct);

    MovieRange range = new MovieRange(vm, 0, vm.size());

    BufferedOutputStream out =
        new BufferedOutputStream(
            new FileOutputStream(
                new File(System.getProperty("user.home"), "Desktop/cat_avc_clip.mp4")));
    IOUtils.copy(range, out);
    out.flush();
    out.close();
  }
Example #2
0
  @Test
  public void testAVCClip() throws IOException {
    File f1 = new File("src/test/resources/AVCClipCatTest/seq_1.mp4");

    MovieBox m1 = MP4Util.parseMovie(f1);

    VirtualTrack t1 =
        new AVCClipTrack(new RealTrack(m1, m1.getVideoTrack(), new FilePool(f1, 10)), 60, 120);

    VirtualMovie vm = new VirtualMP4Movie(t1);

    MovieRange range = new MovieRange(vm, 0, vm.size());

    BufferedOutputStream out =
        new BufferedOutputStream(
            new FileOutputStream(
                new File(System.getProperty("user.home"), "Desktop/precise_clip.mp4")));
    IOUtils.copy(range, out);
    out.flush();
    out.close();
  }
Example #3
0
File: Cut.java Project: 2php/jcodec
  public List<MovieBox> cut(MovieBox movie, List<Slice> commands) {

    TrakBox videoTrack = movie.getVideoTrack();
    if (videoTrack != null && videoTrack.getTimescale() != movie.getTimescale())
      movie.fixTimescale(videoTrack.getTimescale());

    TrakBox[] tracks = movie.getTracks();
    for (int i = 0; i < tracks.length; i++) {
      TrakBox trakBox = tracks[i];
      forceEditList(movie, trakBox);
      List<Edit> edits = trakBox.getEdits();
      for (Slice cut : commands) {
        split(edits, cut.inSec, movie, trakBox);
        split(edits, cut.outSec, movie, trakBox);
      }
    }
    ArrayList<MovieBox> result = new ArrayList<MovieBox>();
    for (Slice cut : commands) {
      MovieBox clone =
          (MovieBox) NodeBox.cloneBox(movie, 16 * 1024 * 1024, BoxFactory.getDefault());
      for (TrakBox trakBox : clone.getTracks()) {
        selectInner(trakBox.getEdits(), cut, movie, trakBox);
      }
      result.add(clone);
    }

    long movDuration = 0;
    for (TrakBox trakBox : movie.getTracks()) {
      selectOuter(trakBox.getEdits(), commands, movie, trakBox);
      trakBox.setEdits(trakBox.getEdits());
      movDuration = max(movDuration, trakBox.getDuration());
    }
    movie.setDuration(movDuration);

    return result;
  }