Examples of IVideoPicture


Examples of com.xuggle.xuggler.IVideoPicture

  }
 
  @Test
  public void testGetBlankFrame()
  {
    IVideoPicture frame = null;
    byte y = 62;
    byte u = 15;
    byte v = 33;
    int w = 100;
    int h = 200;
    long pts = 102832;
   
    frame = Utils.getBlankFrame(w, h, y, u, v, pts);
    assertTrue("got a frame", frame != null);
    assertTrue("is complete", frame.isComplete());
    assertTrue("correct pts", frame.getPts() == pts);

    // now, loop through the array and ensure it is set
    // correctly.
    IBuffer data = frame.getData();
    java.nio.ByteBuffer buffer = data.getByteBuffer(0, data.getBufferSize());
    assertNotNull(buffer);
    // we have the raw data; now we set it to the specified YUV value.
    int lineLength = 0;
    int offset = 0;

    // first let's check the L
    offset = 0;
    lineLength = frame.getDataLineSize(0);
    assertTrue("incorrect format", lineLength == w);
    for(int i = offset ; i < offset + lineLength * h; i++)
    {
      byte val = buffer.get(i);
      assertTrue("color not set correctly: " + i, val == y);
    }

    // now, check the U value
    offset = (frame.getDataLineSize(0)*h);
    lineLength = frame.getDataLineSize(1);
    assertTrue("incorrect format", lineLength == w / 2);
    for(int i = offset ; i < offset + lineLength * h / 2; i++)
    {
      byte val = buffer.get(i);
      assertTrue("color not set correctly: " + i, val == u);
    }

    // and finally the V
    offset = (frame.getDataLineSize(0)*h) + (frame.getDataLineSize(1)*h/2);
    lineLength = frame.getDataLineSize(2);
    assertTrue("incorrect format", lineLength == w / 2);
    for(int i = offset; i < offset + lineLength * h / 2; i++)
    {
      byte val = buffer.get(i);
      assertTrue("color not set correctly: " + i, val == v);
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  @Test
  public void testVideoPictureToImageWrongFormatInput()
  {
    if (!IVideoResampler.isSupported(Feature.FEATURE_COLORSPACECONVERSION))
      return;
    IVideoPicture picture = Utils.getBlankFrame(50, 50, 0);
    assertEquals(IPixelFormat.Type.YUV420P, picture.getPixelType());
    Utils.videoPictureToImage(picture);
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  @Test(expected=UnsupportedOperationException.class)
  public void testLGPLBuild()
  {
    if (IVideoResampler.isSupported(Feature.FEATURE_COLORSPACECONVERSION))
      throw new UnsupportedOperationException();
    IVideoPicture picture = Utils.getBlankFrame(50, 50, 0);
    assertEquals(IPixelFormat.Type.YUV420P, picture.getPixelType());
    Utils.videoPictureToImage(picture);
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_FLV1);
    writer.addVideoStream(videoStreamIndex, videoStreamId, codec, w, h);

    // create a place for video pictures

    IVideoPicture picture = IVideoPicture.make(IPixelFormat.Type.YUV420P, w, h);

    // make some pictures

    double deltaTheta = (Math.PI * 2) / 200;
    for (double theta = 0; theta < Math.PI * 2; theta += deltaTheta)
    {
      BufferedImage image = new BufferedImage(w, h,
        BufferedImage.TYPE_3BYTE_BGR);
     
      Graphics2D g = image.createGraphics();
      g.setRenderingHint(
        RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
     
      g.setColor(Color.RED);
      g.rotate(theta, w / 2, h / 2);
     
      g.fillRect(50, 50, 100, 100);

      picture.setPts(time);
      writer.encodeVideo(videoStreamIndex, image,
          time, Global.DEFAULT_TIME_UNIT);
     
      time += deltaTime;
    }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    int sampleCount = stream.getStreamCoder().getDefaultAudioFrameSize();

    // create a place for audio samples and video pictures

    IAudioSamples samples = IAudioSamples.make(sampleCount, channelCount);
    IVideoPicture picture = IVideoPicture.make(IPixelFormat.Type.YUV420P, w, h);

    // create the tone generator

    TestAudioSamplesGenerator generator = new TestAudioSamplesGenerator();
    generator.prepare(channelCount, sampleRate);

    // make some media

    long videoTime = 0;
    long audioTime = 0;
    long totalSamples = 0;
    long totalSeconds = 6;

    // the goal is to get 6 seconds of audio and video, in this case
    // driven by audio, but kicking out a video frame at about the right
    // time

    while (totalSamples < sampleRate * totalSeconds)
    {
      // comput the time based on the number of samples

      audioTime = (totalSamples * 1000 * 1000) / sampleRate;

      // if the audioTime i>= videoTime then it's time for a video frame

      if (audioTime >= videoTime)
      {
        BufferedImage image = new BufferedImage(w, h,
          BufferedImage.TYPE_3BYTE_BGR);
     
        Graphics2D g = image.createGraphics();
        g.setRenderingHint(
          RenderingHints.KEY_ANTIALIASING,
          RenderingHints.VALUE_ANTIALIAS_ON);

        double theta = videoTime / 1000000d;
        g.setColor(Color.RED);
        g.rotate(theta, w / 2, h / 2);
       
        g.fillRect(50, 50, 100, 100);
       
        picture.setPts(videoTime);
        writer.encodeVideo(videoStreamIndex, image, videoTime,
            Global.DEFAULT_TIME_UNIT);
     
        videoTime += deltaTime;
      }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  private void decodeVideo(IStreamCoder videoCoder, IPacket packet)
  {
    // create a blank video picture
   
    IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
        videoCoder.getWidth(), videoCoder.getHeight());
    try {
      // decode the packet into the video picture

      int rv = videoCoder.decodeVideo(picture, packet, 0);
      if (rv < 0)
        throw new RuntimeException("error " + getErrorMessage(rv)
            + " decoding video");

      // if this is a complete picture, dispatch the picture

      if (picture.isComplete())
        dispatchVideoPicture(packet.getStreamIndex(), picture);
    } finally {
      if (picture != null) picture.delete();
    }
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    for(int i = 0; i < buffer.getBufferSize(); i++)
    {
      bytes[0] = (byte)i;
      buffer.put(bytes, 0, i, 1);
    }
    IVideoPicture picture = IVideoPicture.make(buffer, format, width, height);
    assertNotNull(picture);
    assertEquals(buffer.getBufferSize(), picture.getSize());
   
    for(int i = 0; i < picture.getSize(); i++)
    {
      picture.get(i, bytes, 0, 1);
      assertEquals((byte)i, bytes[0]);
    }
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    }
  }
  @Test
  public void testFrameCreation()
  {
    IVideoPicture frame = null;
   
    frame = IVideoPicture.make(IPixelFormat.Type.RGB24, 320, 240);
    assertTrue("could not get frame", frame != null);
    assertTrue("should default to keyframe", frame.isKeyFrame());
    assertTrue("should not be complete", !frame.isComplete());
    assertEquals("wrong width", frame.getWidth(), 320);
    assertEquals("wrong height", frame.getHeight(), 240);
    assertEquals("wrong format", frame.getPixelType(), IPixelFormat.Type.RGB24);

    frame.delete();
    frame = null;
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  }
 
  @Test
  public void testGetPictureType()
  {
    IVideoPicture pict = Utils.getBlankFrame(10, 10, 0);
    IVideoPicture.PictType defaultType = IVideoPicture.PictType.DEFAULT_TYPE;
    IVideoPicture.PictType setType = IVideoPicture.PictType.S_TYPE;
    assertEquals(defaultType, pict.getPictureType());
    pict.setPictureType(setType);
    assertEquals(setType,pict.getPictureType());
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

        break;
      }
    }
    assertTrue("Could not find video stream", videoStream >= 0);
   
    IVideoPicture picture = IVideoPicture.make(buffer,
        h.mCoders[videoStream].getPixelType(),
        h.mCoders[videoStream].getWidth(),
        h.mCoders[videoStream].getHeight());
    assertNotNull(picture);
    while (h.mContainer.readNextPacket(h.mPacket) == 0)
    {
      if (h.mPacket.getStreamIndex() == videoStream)
      {
        int offset = 0;
        while (offset < h.mPacket.getSize())
        {
          retval = h.mCoders[videoStream].decodeVideo(
              picture,
              h.mPacket,
              offset);
          assertTrue("could not decode any video", retval >0);
          offset += retval;
          if (picture.isComplete())
          {
            totalFrames ++;
            if (picture.isKeyFrame())
              totalKeyFrames++;
          }
        }
      } else {
        log.debug("skipping audio packet");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.