Package com.xuggle.xuggler

Examples of com.xuggle.xuggler.IContainer


    writer.addVideoStream(videoStreamIndex, videoStreamId, videoCodec, w, h);

    // add the audio stream

    ICodec audioCodec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_MP3);
    IContainer container = writer.getContainer();
    IStream stream = container.getStream(writer.addAudioStream(audioStreamIndex, audioStreamId,
      audioCodec, channelCount, sampleRate));
    int sampleCount = stream.getStreamCoder().getDefaultAudioFrameSize();

    // create a place for audio samples and video pictures
View Full Code Here


    IMediaWriter writer = new MediaWriter(file.toString());

    // add the audio stream

    ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_MP3);
    IContainer container = writer.getContainer();
    IStream stream = container.getStream(
        writer.addAudioStream(audioStreamIndex, audioStreamId,
            codec, channelCount, sampleRate));
    int sampleCount = stream.getStreamCoder().getDefaultAudioFrameSize();

    // create a place for audio samples
View Full Code Here

    writer.setMaskLateStreamExceptions(true);

    // add the audio stream

    ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_MP3);
    IContainer container = writer.getContainer();
    IStream stream = container.getStream(
        writer.addAudioStream(audioStreamIndex, audioStreamId,
            codec, channelCount, sampleRate));
    int sampleCount = stream.getStreamCoder().getDefaultAudioFrameSize();

    // create a place for audio samples
View Full Code Here

    if (getMode() == Mode.DISABLED)
      return;

    // get the coder, and stream index

    IContainer container = event.getSource().getContainer();
    IStream stream = container.getStream(event.getStreamIndex());
    IStreamCoder coder = stream.getStreamCoder();
    int streamIndex = event.getStreamIndex();

    // if video stream and showing video, configure video stream
View Full Code Here

   
    final int[] counts = new int[2];

    // create the container
   
    IContainer container = IContainer.make();
   
    // open the container
   
    if (container.open(TEST_FILE_20_SECONDS, IContainer.Type.READ,
        null, false, true) < 0)
      throw new IllegalArgumentException(
        "could not open: " + TEST_FILE_20_SECONDS);
       
    // create a new media reader

    MediaReader mr = new MediaReader(container);
    mr.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
    mr.addListener(new MediaViewer(mViewerMode, true));

    // setup the the listener

    IMediaListener mrl = new MediaListenerAdapter()
      {
        public void onVideoPicture(IVideoPictureEvent event)
        {
          assertNotNull("picture should be created", event.getPicture());
          assertNotNull("buffered image should be created", event.getImage());
          ++counts[0];
        }

        public void onAudioSamples(IAudioSamplesEvent event)
        {
          assertNotNull("audio samples should be created", event.getAudioSamples());
          ++counts[1];
        }
      };
    mr.addListener(mrl);

    // read all the packets in the media file

    IError err = null;
    while ((err = mr.readPacket()) == null)
      ;

    // should be at end of file

    assertEquals("Loop should complete with an EOF",
        IError.Type.ERROR_EOF,
        err.getType());

    // should have read out the correct number of audio and video frames
   
    assertEquals("incorrect number of video frames:",
        counts[0],
        TEST_FILE_20_SECONDS_VIDEO_FRAME_COUNT);
    assertEquals("incorrect number of audio frames:",
        counts[1],
        TEST_FILE_20_SECONDS_AUDIO_FRAME_COUNT);

    // the container should exist
   
    assertTrue("container should be open", container.isOpened());

    // there should exist two streams

    assertEquals("container should have two streams",
      2, container.getNumStreams());

    // both streams should be closed

    for (int i = 0; i < container.getNumStreams(); ++i)
      assertFalse(container.getStream(i).getStreamCoder().isOpen());
  }
View Full Code Here

    int gops = -1;
    IPixelFormat.Type pixFmt= IPixelFormat.Type.NONE;
    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

   * Regression test for https://sourceforge.net/tracker2/?func=detail&aid=2508480&group_id=248424&atid=1126411
   */
  @Test
  public void testGetCodecTypeBugFix2508480()
  {
    IContainer container = IContainer.make();
    assertTrue("should be able to open",
        container.open("fixtures/subtitled_video.mkv", IContainer.Type.READ, null) >= 0);
    assertEquals("unexpected codec type", ICodec.Type.CODEC_TYPE_VIDEO, container.getStream(0).getStreamCoder().getCodecType());
    assertEquals("unexpected codec type", ICodec.Type.CODEC_TYPE_AUDIO, container.getStream(1).getStreamCoder().getCodecType());
    assertEquals("unexpected codec type", ICodec.Type.CODEC_TYPE_SUBTITLE, container.getStream(2).getStreamCoder().getCodecType());
  }
View Full Code Here

  }

  @Test
  public void testGetCodecTag()
  {
    IContainer container = IContainer.make();
    assertTrue("should be able to open",
        container.open("fixtures/subtitled_video.mkv", IContainer.Type.READ, null) >= 0);
    IStreamCoder coder = container.getStream(0).getStreamCoder();
   
    assertEquals("should be 0 by default", 0, coder.getCodecTag());
    coder.setCodecTag(0xDEADBEEF);
    assertEquals("should be set now", 0xDEADBEEF, coder.getCodecTag());
  }
View Full Code Here

  }

  @Test
  public void testGetCodecTagArray()
  {
    IContainer container = IContainer.make();
    assertTrue("should be able to open",
        container.open("fixtures/subtitled_video.mkv", IContainer.Type.READ, null) >= 0);
    IStreamCoder coder = container.getStream(0).getStreamCoder();
  
    char[] tag = coder.getCodecTagArray();
    assertNotNull("should exist", tag);
    assertEquals("should always be 4", 4, tag.length);
    for(int i = 0; i < tag.length; i++)
View Full Code Here

    assertEquals("test value", 0xEF, tag[0]);
  }
 
  public void testSetCodecTagArray()
  {
    IContainer container = IContainer.make();
    assertTrue("should be able to open",
        container.open("fixtures/subtitled_video.mkv", IContainer.Type.READ, null) >= 0);
    IStreamCoder coder = container.getStream(0).getStreamCoder();
  
    char[] tag = new char[4];
    tag[3] = 0xDE;
    tag[2] = 0xAD;
    tag[1] = 0xBE;
View Full Code Here

TOP

Related Classes of com.xuggle.xuggler.IContainer

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.