Exemplo n.º 1
0
  public static void main(String[] args) throws Exception {
    if (args.length < 2) {
      System.out.println("Syntax: <in.mov> <out.mov>");
      return;
    }

    SeekableByteChannel input = readableChannel(new File(args[0]));
    MP4Demuxer demuxer = new MP4Demuxer(input);
    SeekableByteChannel output = writableChannel(new File(args[1]));
    MP4Muxer muxer = MP4Muxer.createMP4Muxer(output, Brand.MOV);

    AbstractMP4DemuxerTrack inVideo = demuxer.getVideoTrack();
    VideoSampleEntry entry = (VideoSampleEntry) inVideo.getSampleEntries()[0];
    int width = entry.getWidth();
    int height = entry.getHeight();
    ProresToProxy toProxy = new ProresToProxy(width, height, 65536);
    FramesMP4MuxerTrack outVideo = muxer.addTrack(TrackType.VIDEO, (int) inVideo.getTimescale());

    TrackHeaderBox th = inVideo.getBox().getTrackHeader();
    System.out.println(toProxy.getFrameSize());
    int frame = 0;
    long from = System.currentTimeMillis();
    long last = from;
    MP4Packet pkt = null;
    while ((pkt = (MP4Packet) inVideo.nextFrame()) != null) {
      ByteBuffer out = ByteBuffer.allocate(pkt.getData().remaining());
      toProxy.transcode(pkt.getData(), out);
      out.flip();
      outVideo.addFrame(MP4Packet.createMP4PacketWithData(pkt, out));
      frame++;
      long cur = System.currentTimeMillis();
      if (cur - last > 5000) {
        System.out.println(((1000 * frame) / (cur - from)) + " fps");
        last = cur;
      }
    }
    entry.setMediaType("apco");
    outVideo.addSampleEntry(entry);

    muxer.writeHeader();
    output.close();
    input.close();
  }
Exemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    if (args.length < 2) {
      System.out.println(
          "Syntax: <in.264> <out.mp4>\n"
              + "\tWhere:\n"
              + "\t-q\tLook for stream parameters only in the beginning of stream");
      return;
    }

    File in = new File(args[0]);
    File out = new File(args[1]);

    SeekableByteChannel file = writableFileChannel(out);
    MP4Muxer muxer = new MP4Muxer(file);
    FramesMP4MuxerTrack track = muxer.addTrackForCompressed(TrackType.VIDEO, 25);

    mux(track, in);

    muxer.writeHeader();

    file.close();
  }