Package com.xuggle.xuggler

Examples of com.xuggle.xuggler.IStream


    // other wise just play the audio directly

    else
    {
      IStream stream = mContainer.getStream(event.getStreamIndex());
      SourceDataLine line = getJavaSoundLine(stream);
      if (line != null)
        playAudio(stream, line, samples);
    }
  }
View Full Code Here


  {
    if (!(tool instanceof IMediaCoder))
      throw new UnsupportedOperationException();

    AudioQueue queue = mAudioQueues.get(streamIndex);
    IStream stream = ((IMediaCoder)tool).getContainer().getStream(streamIndex);
    SourceDataLine line = getJavaSoundLine(stream);
   
    // if no queue (and there is a line), create the queue

    if (null == queue && line != null)
View Full Code Here

    int sampleRate = -1;
    int channels = -1;
   
    IContainer container = IContainer.make();
    container.open("fixtures/testfile.mp3", IContainer.Type.READ, null);
    IStream stream = container.getStream(0);
   
    // get the audio stream
    mCoder = stream.getStreamCoder();
    bitRate = mCoder.getBitRate();
    height = mCoder.getHeight();
    width = mCoder.getWidth();
    timebase = mCoder.getTimeBase();
    gops = mCoder.getNumPicturesInGroupOfPictures();
    pixFmt = mCoder.getPixelType();
    sampleRate = mCoder.getSampleRate();
    channels = mCoder.getChannels();
   
    // Log them all
    log.debug("Bitrate: {}", bitRate);
    log.debug("Height: {}", height);
    log.debug("Width: {}", width);
    log.debug("Timebase: {}", timebase);
    log.debug("Num Group of Pictures: {}", gops);
    log.debug("Pixel Format: {}", pixFmt);
    log.debug("Sample Rate: {}", sampleRate);
    log.debug("Channels: {}", channels);
   
    // now our assertions
    assertEquals(128000, bitRate, 1000);
    assertEquals(0, height);
    assertEquals(0, width);
    assertEquals(1, timebase.getNumerator());
    assertEquals(14112000, timebase.getDenominator());
    assertEquals(12, gops);
    assertEquals(IPixelFormat.Type.NONE, pixFmt);
    assertEquals(44100, sampleRate);
    assertEquals(2, channels);   
    stream.delete();
    container.close();
    container.delete();

  }
View Full Code Here

    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;
View Full Code Here

      throw new IllegalArgumentException(
        "invalid sample rate " + sampleRate);

    // add the new stream at the correct index

    IStream stream = establishStream(inputIndex, streamId, codec);
   
    // configre the stream coder

    IStreamCoder coder = stream.getStreamCoder();
    coder.setChannels(channelCount);
    coder.setSampleRate(sampleRate);
    coder.setSampleFormat(DEFAULT_SAMPLE_FORMAT);

    // add the stream to the media writer
   
    addStream(stream, inputIndex, stream.getIndex());

    // return the new audio stream

    return stream.getIndex();
  }
View Full Code Here

      throw new IllegalArgumentException(
        "invalid video frame size [" + width + " x " + height + "]");

    // add the new stream at the correct index

    IStream stream = establishStream(inputIndex, streamId, codec);
   
    // configre the stream coder

    IStreamCoder coder = stream.getStreamCoder();
    try
    {
      List<IRational> supportedFrameRates = codec.getSupportedVideoFrameRates();
      IRational timeBase = null;
      if (supportedFrameRates != null && supportedFrameRates.size() > 0)
      {
        IRational highestResolution = null;
        // If we have a list of supported frame rates, then
        // we must pick at least one of them.  and if the
        // user passed in a frameRate, it must match
        // this list.
        for(IRational supportedRate: supportedFrameRates)
        {
          if (!IRational.positive(supportedRate))
            continue;
          if (highestResolution == null)
            highestResolution = supportedRate.copyReference();

          if (IRational.positive(frameRate))
          {
            if (supportedRate.compareTo(frameRate) == 0)
              // use this
              highestResolution = frameRate.copyReference();
          }
          else if (highestResolution.getDouble() < supportedRate.getDouble())
          {
            highestResolution.delete();
            highestResolution = supportedRate.copyReference();
          }
          supportedRate.delete();
        }
        // if we had a frame rate suggested, but we
        // didn't find a match among the supported elements,
        // throw an error.
        if (IRational.positive(frameRate) &&
            (highestResolution == null ||
                highestResolution.compareTo(frameRate) != 0))
          throw new UnsupportedOperationException("container does not"+
              " support encoding at given frame rate: " + frameRate);
       
        // if we got through the supported list and found NO valid
        // resolution, fail.
        if (highestResolution == null)
          throw new UnsupportedOperationException(
              "could not find supported frame rate for container: " +
              getUrl());
        if (timeBase == null)
          timeBase = IRational.make(highestResolution.getDenominator(),
              highestResolution.getNumerator());
        highestResolution.delete();
        highestResolution = null;
      }
      // if a positive frame rate was passed in, we
      // should either use the inverse of it, or if
      // there is a supported frame rate, but not
      // this, then throw an error.
      if (IRational.positive(frameRate) && timeBase == null)
      {
        timeBase = IRational.make(
            frameRate.getDenominator(),
            frameRate.getNumerator());
      }
     
      if (timeBase == null)
      {
        timeBase = getDefaultTimebase();
       
        // Finally MPEG4 has some code failing if the time base
        // is too aggressive...
        if (codec.getID() == ICodec.ID.CODEC_ID_MPEG4 &&
            timeBase.getDenominator() > ((1<<16)-1))
        {
          // this codec can't support that high of a frame rate
          timeBase.delete();
          timeBase = IRational.make(1,(1<<16)-1);
        }
      }
      coder.setTimeBase(timeBase);
      timeBase.delete();
      timeBase= null;

      coder.setWidth(width);
      coder.setHeight(height);
      coder.setPixelType(DEFAULT_PIXEL_TYPE);

      // add the stream to the media writer

      addStream(stream, inputIndex, stream.getIndex());
    }
    finally
    {
      coder.delete();
    }

    // return the new video stream

    return stream.getIndex();
  }
View Full Code Here

    if (!isOpen())
      open();

    // add the new stream at the correct index

    IStream stream = getContainer().addNewStream(codec);
    if (stream == null)
      throw new RuntimeException("Unable to create stream id " + streamId +
        ", index " + inputIndex + ", codec " + codec);
   
    // if the stream count is 1, don't force interleave
View Full Code Here

  {
    // establish the stream, return silently if no stream returned
    if (null == picture)
      throw new IllegalArgumentException("no picture");
   
    IStream stream = getStream(streamIndex);
    if (null == stream)
      return;

    // verify parameters

    Integer outputIndex = getOutputStreamIndex(streamIndex);
    if (null == outputIndex)
      throw new IllegalArgumentException("unknow stream index: " + streamIndex);
    if (CODEC_TYPE_VIDEO  != mStreams.get(outputIndex).getStreamCoder()
      .getCodecType())
    {
      throw new IllegalArgumentException("stream[" + streamIndex +
        "] is not video");
    }
    // encode video picture

    // encode the video packet
   
    IPacket packet = IPacket.make();
    try {
      if (stream.getStreamCoder().encodeVideo(packet, picture, 0) < 0)
        throw new RuntimeException("failed to encode video");
 
      if (packet.isComplete())
        writePacket(packet);
    } finally {
View Full Code Here

    if (null == timeUnit)
      throw new IllegalArgumentException("NULL time unit");

    // try to set up the stream, and if we're not going to encode
    // it, don't bother converting it.
    IStream stream = getStream(streamIndex);
    if (null == stream)
      return;

    // convert the image to a picture and push it off to be encoded
View Full Code Here

  {
    if (null == samples)
      throw new IllegalArgumentException("NULL input samples");
    // establish the stream, return silently if no stream returned

    IStream stream = getStream(streamIndex);
    if (null == stream)
      return;

    IStreamCoder coder = stream.getStreamCoder();
    try
    {
      if (CODEC_TYPE_AUDIO != coder.getCodecType())
      {
        throw new IllegalArgumentException("stream[" + streamIndex +
View Full Code Here

TOP

Related Classes of com.xuggle.xuggler.IStream

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.