Examples of IVideoPicture


Examples of com.xuggle.xuggler.IVideoPicture

 
    IConverter converter = ConverterFactory.createConverter(
      mConverterType.getDescriptor(), mConverterType.getPictureType(),
      size, size);

    IVideoPicture picture = null;
    // construct an image with black and white stripped columns
 
    BufferedImage image1 = new BufferedImage(
      size, size, mConverterType.getImageType());
    for (int x = 0; x < size; ++x)
      for (int y = 0; y < size; ++y)
      {
        int color = x % 2 == 0 ? black : white;
        image1.setRGB(x, y, color);
      }
 
    // convert image1 to a picture and then back to image2
 
    picture = converter.toPicture(image1, 0);
    BufferedImage image2 = converter.toImage(
      picture);
    picture.delete();
 
    // rotate image2 into image3
 
    AffineTransform t = AffineTransform.getRotateInstance(
      Math.PI/2, image2.getWidth() / 2, image2.getHeight() / 2);
    AffineTransformOp ato = new AffineTransformOp(t,
      AffineTransformOp.TYPE_BICUBIC);
    BufferedImage image3 = new BufferedImage(
      size, size, mConverterType.getImageType());
    image3 = ato.filter(image2, image3);
 
    // convert image3 to a picture and then back to an image (4)
 
    picture = converter.toPicture(image3, 0);
    BufferedImage image4 = converter.toImage(picture);
    picture.delete();
 
    // test that image4 now contains stripped rows (not columns)
 
    for (int x = 0; x < size; ++x)
      for (int y = 0; y < size; ++y)
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

      for (int y = 0; y < h1; ++y)
        image1.setRGB(x, y, gray);

    // convert image1 to a picture and then back to image2

    IVideoPicture picture = converter1.toPicture(image1, 0);
    BufferedImage image2 = converter2.toImage(picture);
    picture.delete();

    assertEquals("image2 wrong width", w2, image2.getWidth());
    assertEquals("image2 wrong height", h2, image2.getHeight());

    // test that all the pixels in image2 are gray, but not black or
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    if (null == stream)
      return;

    // convert the image to a picture and push it off to be encoded

    IVideoPicture picture = convertToPicture(streamIndex,
      image, MICROSECONDS.convert(timeStamp, timeUnit));

    try
    {
      encodeVideo(streamIndex, picture, image);
    }
    finally
    {
      if (picture != null)
        picture.delete();
    }
  }
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

    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

      if (packet.getStreamIndex() == videoStreamId)
      {
        /*
         * We allocate a new picture to get the data out of Xuggler
         */
        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());

        int offset = 0;
        while(offset < packet.getSize())
        {
          /*
           * Now, we decode the video, checking for any errors.
           *
           */
          int bytesDecoded = videoCoder.decodeVideo(picture, packet, offset);
          if (bytesDecoded < 0)
            throw new RuntimeException("got error decoding video in: " + deviceName);
          offset += bytesDecoded;

          /*
           * Some decoders will consume data in a packet, but will not be able to construct
           * a full video picture yet.  Therefore you should always check if you
           * got a complete picture from the decoder
           */
          if (picture.isComplete())
          {
            IVideoPicture newPic = picture;
            /*
             * If the resampler is not null, that means we didn't get the video in BGR24 format and
             * need to convert it into BGR24 format.
             */
            if (resampler != null)
            {
              // we must resample
              newPic = IVideoPicture.make(resampler.getOutputPixelFormat(), picture.getWidth(), picture.getHeight());
              if (resampler.resample(newPic, picture) < 0)
                throw new RuntimeException("could not resample video from: " + deviceName);
            }
            if (newPic.getPixelType() != IPixelFormat.Type.BGR24)
              throw new RuntimeException("could not decode video as BGR 24 bit data in: " + deviceName);

            // Convert the BGR24 to an Java buffered image
            BufferedImage javaImage = Utils.videoPictureToImage(newPic);

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
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.