Пример #1
0
 private int calcSpaceReq(MovieBox movie) {
   int sum = 0;
   TrakBox[] tracks = movie.getTracks();
   for (int i = 0; i < tracks.length; i++) {
     TrakBox trakBox = tracks[i];
     ChunkOffsetsBox stco = trakBox.getStco();
     if (stco != null) sum += stco.getChunkOffsets().length * 4;
   }
   return sum;
 }
Пример #2
0
  private void cleanDrefs(TrakBox trak) {
    MediaInfoBox minf = trak.getMdia().getMinf();
    DataInfoBox dinf = trak.getMdia().getMinf().getDinf();
    if (dinf == null) {
      dinf = new DataInfoBox();
      minf.add(dinf);
    }

    DataRefBox dref = dinf.getDref();
    if (dref == null) {
      dref = new DataRefBox();
      dinf.add(dref);
    }

    dref.getBoxes().clear();
    dref.add(AliasBox.createSelfRef());

    for (SampleEntry entry :
        NodeBox.findAll(trak, SampleEntry.class, "mdia", "minf", "stbl", "stsd", null)) {
      entry.setDrefInd((short) 1);
    }
  }
Пример #3
0
  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;
  }