Package com.xuggle.xuggler

Examples of com.xuggle.xuggler.IPacket


      for (int consumed = 0; consumed < samples.getNumSamples(); /* in loop */)
      {
        // encode audio

        IPacket packet = IPacket.make();
        try {
          int result = coder.encodeAudio(packet, samples, consumed);
          if (result < 0)
            throw new RuntimeException("failed to encode audio");

          // update total consumed

          consumed += result;

          // if a complete packed was produced write it out

          if (packet.isComplete())
            writePacket(packet);
        } finally {
          if (packet != null)
            packet.delete();
        }
      }      // inform listeners

      super.onAudioSamples(new AudioSamplesEvent(this, samples,
          streamIndex));
View Full Code Here


      // if it's audio coder flush that

      if (CODEC_TYPE_AUDIO == coder.getCodecType())
      {
        IPacket packet = IPacket.make();
        while (coder.encodeAudio(packet, null, 0) >= 0 && packet.isComplete())
        {
          writePacket(packet);
          packet.delete();
          packet = IPacket.make();
        }
        packet.delete();
      }
     
      // else flush video coder

      else if (CODEC_TYPE_VIDEO == coder.getCodecType())
      {
        IPacket packet = IPacket.make();
        while (coder.encodeVideo(packet, null, 0) >= 0 && packet.isComplete())
        {
          writePacket(packet);
          packet.delete();
          packet = IPacket.make();
        }
        packet.delete();
      }
    }

    // flush the container
View Full Code Here

    openJavaWindow();

    /*
     * Now, we start walking through the container looking at each packet.
     */
    IPacket packet = IPacket.make();
    long firstTimestampInStream = Global.NO_PTS;
    long systemClockStartTime = 0;
    while(container.readNextPacket(packet) >= 0)
    {
      /*
       * Now we have a packet, let's see if it belongs to our video stream
       */
      if (packet.getStreamIndex() == videoStreamId)
      {
        /*
         * We allocate a new picture to get the data out of Xuggler
         */
        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());

        int offset = 0;
        while(offset < packet.getSize())
        {
          /*
           * Now, we decode the video, checking for any errors.
           *
           */
 
View Full Code Here

  public void encodeImage(BufferedImage originalImage)
  {
    BufferedImage worksWithXugglerBufferedImage = convertToType(originalImage,
        BufferedImage.TYPE_3BYTE_BGR);
    IPacket packet = IPacket.make();

    long now = System.currentTimeMillis();
    if (firstTimeStamp == -1)
      firstTimeStamp = now;
   
    IConverter converter = null;
    try
    {
      converter = ConverterFactory.createConverter(
          worksWithXugglerBufferedImage, IPixelFormat.Type.YUV420P);
    }
    catch (UnsupportedOperationException e)
    {
      System.out.println(e.getMessage());
      e.printStackTrace(System.out);
    }

    long timeStamp = (now - firstTimeStamp)*1000; // convert to microseconds
    IVideoPicture outFrame = converter.toPicture(worksWithXugglerBufferedImage,
        timeStamp);

    outFrame.setQuality(0);
    int retval = outStreamCoder.encodeVideo(packet, outFrame, 0);
    if (retval < 0)
      throw new RuntimeException("could not encode video");
    if (packet.isComplete())
    {
      retval = outContainer.writePacket(packet);
      if (retval < 0)
        throw new RuntimeException("could not save packet to container");
    }
View Full Code Here

TOP

Related Classes of com.xuggle.xuggler.IPacket

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.