コード例 #1
0
 public static void main(String[] args) throws IOException {
   IsoFile isoFile = new IsoFile(new IsoBufferWrapperImpl(new File("/home/sannies/vw.mp4")));
   Path p = new Path(isoFile);
   isoFile.parse();
   CompositionTimeToSample ctts =
       (CompositionTimeToSample) p.getPath("/moov/trak[1]/mdia/minf/stbl/ctts");
   int[] cts = CompositionTimeToSample.blowupCompositionTimes(ctts.getEntries());
   RawH264Track track =
       new RawH264Track(new IsoBufferWrapperImpl(new File("/home/sannies/vw_track2.h264")));
   // RawH264Track track = new RawH264Track(new IsoBufferWrapperImpl(new
   // File("/home/sannies/suckerpunch-samurai_h640w_track1.h264")));
 }
コード例 #2
0
 @Override
 public void changed(
     ObservableValue<? extends TreeItem<Box>> observableValue,
     TreeItem<Box> boxTreeItem,
     TreeItem<Box> boxTreeItem2) {
   if (boxTreeItem2 == null) {
     return;
   }
   String id = Path.createPath(boxTreeItem2.getValue());
   Tab t = null;
   for (Tab tab : tabPane.getTabs()) {
     if (tab.getId().equals(id)) {
       tabPane.getSelectionModel().select(tab);
       t = tab;
     }
   }
   if (t == null) {
     t = new Tab(id);
     t.setId(id);
     tabPane.getTabs().addAll(t);
     t.setContent(new BoxPane(boxTreeItem2.getValue()));
     tabPane.getSelectionModel().select(t);
   }
 }
コード例 #3
0
  /** {@inheritDoc} */
  public Container build(Movie movie) {
    if (fragmenter == null) {
      fragmenter = new TimeBasedFragmenter(2);
    }
    LOG.fine("Creating movie " + movie);
    for (Track track : movie.getTracks()) {
      // getting the samples may be a time consuming activity
      List<Sample> samples = track.getSamples();
      putSamples(track, samples);
      long[] sizes = new long[samples.size()];
      for (int i = 0; i < sizes.length; i++) {
        Sample b = samples.get(i);
        sizes[i] = b.getSize();
      }
      track2SampleSizes.put(track, sizes);
    }

    BasicContainer isoFile = new BasicContainer();

    isoFile.addBox(createFileTypeBox(movie));

    Map<Track, int[]> chunks = new HashMap<Track, int[]>();
    for (Track track : movie.getTracks()) {
      chunks.put(track, getChunkSizes(track));
    }
    Box moov = createMovieBox(movie, chunks);
    isoFile.addBox(moov);
    List<SampleSizeBox> stszs = Path.getPaths(moov, "trak/mdia/minf/stbl/stsz");

    long contentSize = 0;
    for (SampleSizeBox stsz : stszs) {
      contentSize += sum(stsz.getSampleSizes());
    }

    InterleaveChunkMdat mdat = new InterleaveChunkMdat(movie, chunks, contentSize);
    isoFile.addBox(mdat);

    /*
    dataOffset is where the first sample starts. In this special mdat the samples always start
    at offset 16 so that we can use the same offset for large boxes and small boxes
     */
    long dataOffset = mdat.getDataOffset();
    for (StaticChunkOffsetBox chunkOffsetBox : chunkOffsetBoxes.values()) {
      long[] offsets = chunkOffsetBox.getChunkOffsets();
      for (int i = 0; i < offsets.length; i++) {
        offsets[i] += dataOffset;
      }
    }
    for (SampleAuxiliaryInformationOffsetsBox saio : sampleAuxiliaryInformationOffsetsBoxes) {
      long offset =
          saio.getSize(); // the calculation is systematically wrong by 4, I don't want to debug
      // why. Just a quick correction --san 14.May.13
      offset += 4 + 4 + 4 + 4 + 4 + 24;
      // size of all header we were missing otherwise (moov, trak, mdia, minf, stbl)
      Object b = saio;
      do {
        Object current = b;
        b = ((Box) b).getParent();

        for (Box box : ((Container) b).getBoxes()) {
          if (box == current) {
            break;
          }
          offset += box.getSize();
        }

      } while (b instanceof Box);

      long[] saioOffsets = saio.getOffsets();
      for (int i = 0; i < saioOffsets.length; i++) {
        saioOffsets[i] = saioOffsets[i] + offset;
      }
      saio.setOffsets(saioOffsets);
    }

    return isoFile;
  }