Hi,
I am trying to publish a screencapture video to wowza. I have a code, but it stop at a certain point. It canot process the following line:
int bytesDecoded = videoDecoder.decodeVideo(videoPicture, packet, 0);
If you can help me in this matter please let me know.
When I tried the code (from here: http://www.brokenmill.com/2010/08/xuggler-rtmp-howto/comment-page-1/#comment-14350) , I get an error on line 34 (real-work part – when a decodeVideo() method is called.)
This is the line that xuggler writes out:
13:24:43.759 [Thread-2] ERROR org.ffmpeg – [mpeg4 @ 045B74A0] header damaged
java.lang.Exception: Cannot decode video picture (pacet size: 43629)
Before that I create the IBuffer from a screenshot. This is what I do:
BufferedImage screen = robot.createScreenCapture(areaToRecord);
BufferedImage image = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), TYPE_3BYTE_BGR);
image.getGraphics().drawImage(sourceImage, 0, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, “jpg”, baos);
baos.flush();
byte[] data = baos.toByteArray();
baos.close();
IBuffer iBuffer = IBuffer.make(null, data, 0, data.length);
IPacket packet = IPacket.make(iBuffer);
packet.setTimeStamp(timeStamp);
packet.setKeyPacket(true);
packet.setTimeBase(IRational.make(1,1000));
packet.setTimeStamp(timeStamp);
packet.setDuration(tsInterval);
packet.setPts(lastVideoPts);
packet.setDts(lastVideoPts);
packet.setPosition(lastPos);
lastPos += data.length;
videoFrameCnt++;
int pksz = packet.getSize();
packet.setComplete(true, pksz);
IVideoPicture videoPicture = IVideoPicture.make(IPixelFormat.Type.YUV420P, width, height);
int bytesDecoded = videoDecoder.decodeVideo(videoPicture, packet, 0);
if (bytesDecoded < 0) {
throw new Exception("Cannot decode video picture (pacet size: " + pksz + “)”);
}
Can you please let me now what I am doing incorrectly? Ultimately I would like to publish this to a wowza server. I tried to take out the decoding and resampling part and just send the packet (created from the IBuffer) to the output stream. The server accepted it, but the file saved on the server was not playable.
Thanks,
Zoltan