Package com.xuggle.xuggler

Examples of com.xuggle.xuggler.IStreamCoder


    for(int i = 0; i < numStreams; i++)
    {
      // Find the stream object
      IStream stream = container.getStream(i);
      // Get the pre-configured decoder that can decode this stream;
      IStreamCoder coder = stream.getStreamCoder();
     
      // and now print out the meta data.
      System.out.printf("stream %d: ",    i);
      System.out.printf("type: %s; ",     coder.getCodecType());
      System.out.printf("codec: %s; ",    coder.getCodecID());
      System.out.printf("duration: %s; ", stream.getDuration() == Global.NO_PTS ? "unknown" : "" + stream.getDuration());
      System.out.printf("start time: %s; ", container.getStartTime() == Global.NO_PTS ? "unknown" : "" + stream.getStartTime());
      System.out.printf("language: %s; ", stream.getLanguage() == null ? "unknown" : stream.getLanguage());
      System.out.printf("timebase: %d/%d; ", stream.getTimeBase().getNumerator(), stream.getTimeBase().getDenominator());
      System.out.printf("coder tb: %d/%d; ", coder.getTimeBase().getNumerator(), coder.getTimeBase().getDenominator());
     
      if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO)
      {
        System.out.printf("sample rate: %d; ", coder.getSampleRate());
        System.out.printf("channels: %d; ",    coder.getChannels());
        System.out.printf("format: %s",        coder.getSampleFormat());
      } else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
      {
        System.out.printf("width: %d; ",  coder.getWidth());
        System.out.printf("height: %d; ", coder.getHeight());
        System.out.printf("format: %s; ", coder.getPixelType());
        System.out.printf("frame-rate: %5.2f; ", coder.getFrameRate().getDouble());
      }
      System.out.printf("\n");
    }
   
  }
View Full Code Here


    mStreams.put(outputStreamIndex, stream);

    // if this is a video coder, set the quality

    IStreamCoder coder = stream.getStreamCoder();
    if (CODEC_TYPE_VIDEO == coder.getCodecType())
      coder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
   
    // inform listeners

    super.onAddStream(new AddStreamEvent(this, outputStreamIndex));
  }
View Full Code Here

  private void openStream(IStream stream)
  {
    // if the coder is not open, open it NOTE: MediaWriter currently
    // supports audio & video streams
   
    IStreamCoder coder = stream.getStreamCoder();
    try
    {
      ICodec.Type type = coder.getCodecType();
      if (!coder.isOpen() && isSupportedCodecType(type))
      {
        // open the coder

        int rv = coder.open(null, null);
        if (rv < 0)
          throw new RuntimeException("could not open stream " + stream + ": "
              + getErrorMessage(rv));
        mOpenedStreams.add(stream);

        // inform listeners
        super.onOpenCoder(new OpenCoderEvent(this, stream.getIndex()));
      }
    }
    finally
    {
      coder.delete();
    }
  }
View Full Code Here

  {
    // flush coders

    for (IStream stream: mStreams.values())
    {
      IStreamCoder coder = stream.getStreamCoder();
      if (!coder.isOpen())
        continue;

      // 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();
        }
View Full Code Here

   
    // close the coders opened by this MediaWriter

    for (IStream stream: mOpenedStreams)
    {
      IStreamCoder coder = stream.getStreamCoder();
      try
      {
        if ((rv = coder.close()) < 0)
          throw new RuntimeException("error "
              + getErrorMessage(rv)
              + ", failed close coder " + coder);

        // inform the listeners
        super.onCloseCoder(new CloseCoderEvent(this, stream.getIndex()));
      }
      finally
      {
        coder.delete();
      }
    }

    // expunge all referneces to the coders and resamplers
   
View Full Code Here

    int numStreams = container.getNumStreams();

    // and iterate through the streams to find the first video stream

    int videoStreamId = -1;
    IStreamCoder videoCoder = null;
    for(int i = 0; i < numStreams; i++)
    {
      // find the stream object

      IStream stream = container.getStream(i);

      // get the pre-configured decoder that can decode this stream;

      IStreamCoder coder = stream.getStreamCoder();

      if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
      {
        videoStreamId = i;
        videoCoder = coder;
        break;
      }
View Full Code Here

    // query how many streams the call to open found
    int numStreams = container.getNumStreams();

    // and iterate through the streams to find the first video stream
    int videoStreamId = -1;
    IStreamCoder videoCoder = null;
    for(int i = 0; i < numStreams; i++)
    {
      // Find the stream object
      IStream stream = container.getStream(i);
      // Get the pre-configured decoder that can decode this stream;
      IStreamCoder coder = stream.getStreamCoder();

      if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
      {
        videoStreamId = i;
        videoCoder = coder;
        break;
      }
View Full Code Here

    // query how many streams the call to open found
    int numStreams = container.getNumStreams();
   
    // and iterate through the streams to find the first audio stream
    int videoStreamId = -1;
    IStreamCoder videoCoder = null;
    int audioStreamId = -1;
    IStreamCoder audioCoder = null;
    for(int i = 0; i < numStreams; i++)
    {
      // Find the stream object
      IStream stream = container.getStream(i);
      // Get the pre-configured decoder that can decode this stream;
      IStreamCoder coder = stream.getStreamCoder();
     
      if (videoStreamId == -1 && coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
      {
        videoStreamId = i;
        videoCoder = coder;
      }
      else if (audioStreamId == -1 && coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO)
      {
        audioStreamId = i;
        audioCoder = coder;
      }
    }
View Full Code Here

 
  public void testGetStreamCoder()
  {
    helperGetStream(0);
   
    IStreamCoder coder = null;
    coder = mStream.getStreamCoder();
    assertTrue(coder != null);
  }
View Full Code Here

    writer = new MediaWriter(PREFIX+
      "testTimebaseGuessingWhenCodecSpecifiedAllowed2.mpg");
    writer.addVideoStream(0,
        0,
        100, 100);
    IStreamCoder coder = writer.getContainer().getStream(0).getStreamCoder();
    // should have set the highest possible
    assertEquals(1, coder.getTimeBase().getNumerator());
    assertEquals(60, coder.getTimeBase().getDenominator());
  }
View Full Code Here

TOP

Related Classes of com.xuggle.xuggler.IStreamCoder

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.