Package org.red5.io.mp4.impl

Examples of org.red5.io.mp4.impl.MP4


     */
  private void writeMetadataTag(double duration, Integer videoCodecId, Integer audioCodecId) throws IOException {
    metaPosition = channel.position();
    IoBuffer buf = IoBuffer.allocate(1024);
    buf.setAutoExpand(true);
    Output out = new Output(buf);
    out.writeString("onMetaData");
    Map<Object, Object> params = new HashMap<Object, Object>(4);
    params.put("duration", duration);
    if (videoCodecId != null) {
      params.put("videocodecid", videoCodecId.intValue());
    }
    if (audioCodecId != null) {
      params.put("audiocodecid", audioCodecId.intValue());
    }
    params.put("canSeekToEnd", true);
    out.writeMap(params, new Serializer());
    buf.flip();

    if (fileMetaSize == 0) {
      fileMetaSize = buf.limit();
    }
View Full Code Here


   *
   * @throws IOException      Any I/O exception
   */
  public void writeHeader() throws IOException {
    //Header fields (in same order than spec, for comparison purposes)
    FLVHeader flvHeader = new FLVHeader();
    flvHeader.setSignature("FLV".getBytes());
    flvHeader.setVersion ((byte)0x01);
    flvHeader.setFlagReserved01 ((byte) 0x0);
    flvHeader.setFlagAudio (true);
    flvHeader.setFlagReserved02 ((byte) 0x0);
    flvHeader.setFlagVideo (true);
    flvHeader.write(out);
   
    //Dump header to output channel
    channel.write(out.buf());
  }
View Full Code Here

    if (writer != null && !this.isClosed) {
      try {
       
        log.debug("#################### -start- closeStream ########################");
        log.debug("#################### -start- closeStream ########################");
        FLVWriter flvWriter = (FLVWriter) writer;
        //log.debug("duration: "+flvWriter.getDuration());
        //log.debug(writer.getClass().getName());
       
        writer.close();
       
View Full Code Here

       
        int timeStamp = streampacket.getTimestamp();
       
        timeStamp -= startTimeStamp;
       
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
       
        if (this.isInterview) {
          if (timeStamp <= 500) {
            //We will cut the first 0.5 seconds
View Full Code Here

    if (fileMetaSize == 0) {
      fileMetaSize = buf.limit();
    }

    ITag onMetaData = new Tag(ITag.TYPE_METADATA, 0, fileMetaSize, buf, 0);
    writeTag(onMetaData);
  }
View Full Code Here

         
          FlvRecordingMetaDeltaDaoImpl.getInstance().addFlvRecordingMetaDelta(flvRecordingMetaDelta);
         
        }
       
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        writer.writeTag(tag);
     
      }
     
View Full Code Here

//           
//          }
         
        }
             
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        //log.debug("duration: "+flvWriter.getDuration());
       
        if (debug) {
         
          String filePath = folderPath + File.separatorChar
              + "Packet"
              +"_t_"+tag.getTimestamp()
              +"_d_"+deltaTime
              +"_s_"+tag.getBodySize()
              +".flv";
         
          //File out = new File();
         
          FLVDebugWriter flvWriterDebug = new FLVDebugWriter( new File( filePath ), false);
         
          flvWriterDebug.writeBytesFromTag(streampacket.getData().asReadOnlyBuffer());

          flvWriterDebug.closeBytesFile();
         
        }

        writer.writeTag(tag);
 
      } else if (streampacket.getDataType() == 9) {
       
        //Video data is handled just without calculating deltas
        int timeStamp = streampacket.getTimestamp();
       
        timeStamp -= startTimeStamp;
       
        ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        writer.writeTag(tag);
       
      }
     
View Full Code Here

    log.debug("Test sort");
   
    List<MP4Frame> frames = new ArrayList<MP4Frame>(6);
   
    //create some frames
    MP4Frame frame1 = new MP4Frame();
    frame1.setTime(1);
    frame1.setOffset(1);
    frames.add(frame1);
   
    MP4Frame frame2 = new MP4Frame();
    frame2.setTime(6);
    frame2.setOffset(6);
    frames.add(frame2);
   
    MP4Frame frame3 = new MP4Frame();
    frame3.setTime(660);
    frame3.setOffset(660);
    frames.add(frame3);
   
    MP4Frame frame4 = new MP4Frame();
    frame4.setTime(3);
    frame4.setOffset(3);
    frames.add(frame4);
   
    MP4Frame frame5 = new MP4Frame();
    frame5.setTime(400);
    frame5.setOffset(400);   
    frames.add(frame5);

    MP4Frame frame6 = new MP4Frame();
    frame6.setTime(1000);
    frame6.setOffset(1010);
    frames.add(frame6);
   
    MP4Frame frame7 = new MP4Frame();
    frame7.setTime(1000);
    frame7.setOffset(1000);
    frames.add(frame7);   

    MP4Frame frame8 = new MP4Frame();
    frame8.setTime(1000);
    frame8.setOffset(900);
    frames.add(frame8);     
   
    System.out.printf("Frame 1 - time: %s (should be 660)\n", frames.get(2).getTime());

    Collections.sort(frames);
View Full Code Here

  /** {@inheritDoc}
   */
  @Override
  public IStreamableFile getStreamableFile(File file) throws IOException {
    return new MP4(file);
  }
View Full Code Here

    //File file = new File("M:/backup/media/test_clips/0608071221.3g2");
    //File file = new File("M:/backup/media/test_clips/test1.3gp");
    //File file = new File("M:/backup/media/test_clips/ANewHope.mov");
    File file = new File("M:/Movies/Hitman.m4v"); // has pasp atom

    MP4Reader reader = new MP4Reader(file);

    KeyFrameMeta meta = reader.analyzeKeyFrames();
    log.debug("Meta: {}", meta);

    ITag tag = null;
    for (int t = 0; t < 32; t++) {
      tag = reader.readTag();
      log.debug("Tag: {}", tag);
    }

    log.info("----------------------------------------------------------------------------------");
View Full Code Here

TOP

Related Classes of org.red5.io.mp4.impl.MP4

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.