Package com.xuggle.mediatool

Examples of com.xuggle.mediatool.MediaReader


      MediaViewer.Mode viewerMode)
  {
    JNIMemoryManager.setMemoryModel(model);
    for(int i = 0; i < numIterations; i++)
    {
      MediaReader reader = new MediaReader(url);
      MediaWriter writer = null;
      assertNotNull(reader);
      if (doWrite) {
        String outURL =
          MediaToolExhaustiveTest.class.getName()+"_"+
          model + "_" +
          i + ".mov";
        // adds itself to the reader
        writer = new MediaWriter(outURL, reader);
        reader.addListener(writer);
      }
      if (doViewer)
      {
        MediaViewer viewer = new MediaViewer(viewerMode,
            true,
            WindowConstants.EXIT_ON_CLOSE);
        reader.addListener(viewer);
         
      }
      while(reader.readPacket() == null)
        /* continue */ ;
    }
  }
View Full Code Here


  MediaReader mReader;

  @Before
    public void beforeTest()
  {
    mReader = new MediaReader(TEST_FILE);
    mReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
  }
View Full Code Here

    File outputFile = new File(OUTPUT_FILENAME);
    assert(inputFile.exists());
    outputFile.delete();
    assert(!outputFile.exists());

    MediaReader reader = new MediaReader(INPUT_FILENAME);
    MediaWriter writer = new MediaWriter(OUTPUT_FILENAME, reader);
    reader.addListener(writer);

    writer.addListener(new MediaViewer(mViewerMode, true, 0));

    MediaDebugListener readerCounter = new MediaDebugListener(URL, META_DATA);
    MediaDebugListener writerCounter = new MediaDebugListener(EVENT, META_DATA);

    reader.addListener(readerCounter);
    writer.addListener(writerCounter);

   
    IError rv;
    while ((rv = reader.readPacket()) == null)
      ;

    assertEquals(IError.Type.ERROR_EOF    , rv.getType());

    assertEquals(READER_VIDEO_FRAME_COUNT , readerCounter.getCount(VIDEO));
View Full Code Here

    destinationFile.delete();
    assert(!destinationFile.exists());

    // create the reader

    MediaReader reader = new MediaReader(mSource);

    // construct a writer which does not get called directly by the
    // MediaReader, and thus many things need to be handled manually

    if (mTestContainer)
    {
      final MediaWriter writer = new MediaWriter(mDestination,
        reader.getContainer());
      writer.setMaskLateStreamExceptions(false);
      writer.addListener(new MediaViewer(mViewerMode, true));

      writer.addListener(new MediaDebugListener(OPEN, CLOSE));

      reader.addListener(new MediaListenerAdapter()
        {
          public void onVideoPicture(IVideoPictureEvent event)
          {
            writer.onVideoPicture(event);
          }
         
          /** {@inheritDoc} */
         
          public void onAudioSamples(IAudioSamplesEvent event)
          {
            writer.onAudioSamples(event);
          }
        });

      // transcode

      while (reader.readPacket() == null)
        ;

      // close the container
     
      writer.close();
    }

    // construct a writer give a reader, the easy simple case

    else
    {
      // construct the writer, no need to keep a reference to the
      // writer, it's maintained in the reader

      MediaWriter writer = new MediaWriter(mDestination, reader);
      reader.addListener(writer);
      writer.setMaskLateStreamExceptions(false);
      writer.addListener(new MediaViewer(mViewerMode, true));

      writer.addListener(new MediaDebugListener(EVENT, META_DATA));

      // transcode

      while (reader.readPacket() == null)
        ;
    }

    // confirm file exists and has at least 50k of data

View Full Code Here

  MediaReader mReader;

  @Before
    public void beforeTest()
  {
    mReader = new MediaReader(TEST_FILE);
    mReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
  }
View Full Code Here

    File outputFile = new File(OUTPUT_FILENAME);
    assert(inputFile.exists());
    outputFile.delete();
    assert(!outputFile.exists());

    MediaReader reader = new MediaReader(INPUT_FILENAME);
    MediaWriter writer = new MediaWriter(OUTPUT_FILENAME, reader);
    reader.addListener(writer);

    writer.addListener(new MediaViewer(mViewerMode, true, 0));

    MediaDebugListener readerCounter = new MediaDebugListener(URL, META_DATA);
    MediaDebugListener writerCounter = new MediaDebugListener(EVENT, META_DATA);

    reader.addListener(readerCounter);
    writer.addListener(writerCounter);

   
    IError rv;
    while ((rv = reader.readPacket()) == null)
      ;

    assertEquals(IError.Type.ERROR_EOF    , rv.getType());

    assertEquals(READER_VIDEO_FRAME_COUNT , readerCounter.getCount(VIDEO));
View Full Code Here

  // create a new media reader with a bad filename

  @Test(expected=RuntimeException.class)
    public void testMediaSourceNotExist()
  {
    IMediaReader mr = new MediaReader("broken" + TEST_FILE_20_SECONDS);
    mr.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);

    mr.readPacket();
 
View Full Code Here

  {
    final int[] counts = new int[2];
    // create a new media reader

    MediaReader mr = new MediaReader(TEST_FILE_20_SECONDS);
    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());
          assertNull("no 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",
View Full Code Here

        IVideoResampler.Feature.FEATURE_COLORSPACECONVERSION))
      return;
   
    // create a new media reader

    MediaReader mr = new MediaReader(TEST_FILE_20_SECONDS);
    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());
        }

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

    // read all the packets in the media file

    while (mr.readPacket() == null)
      ;
  }
View Full Code Here

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

TOP

Related Classes of com.xuggle.mediatool.MediaReader

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.