Hi,
right now i am going through two different issues
1.) changing the resolution
2.) changing the format of picture
and both the above task can be done once i decode an incoming video
packet into an IVideoPicture, this pic contains the raw data of same
format. so far there is no issue with that.
now
1.) regarding changing the resolution from QVGA to QCIF
i tried the below code snippet,
IVideoPicture newPict = IVideoPicture.make(IPixelFormat.Type.YUV420P,
176, 144);
newPict.copy(pic);
newPict.setComplete(true, IPixelFormat.Type.YUV420P, 176, 144, 0);
outStreamCoder.encodeVideo(packet, newPict, 0)
but it gives me an error
12:17:01.875 [main] DEBUG com.xuggle.xuggler - error: width does not
match (../../../../../../../csrc/com/xuggle/xuggler/VideoPicture.cpp:
298)
12:17:01.875 [main] ERROR org.ffmpeg - [mpeg4 @ 0x2d31200] Error,
Invalid timestamp=0, last=0
Unable to encode into low resolution
12:17:01.875 [main] ERROR com.xuggle.xuggler - Error: cannot write
incomplete packet (../../../../../../../csrc/com/xuggle/xuggler/
Container.cpp:584)
2.) Regarding changing the format, i applied the below approach
i make another IvideoPicture of type RGB24 and put the raw picture
data (got after decoding the incoming video packet).
afterwards i called setComplete method.
you can see the step i followed, from the below code snippet
IVideoPicture jpegPict = IVideoPicture.make(IPixelFormat.Type.RGB24,
videoCoder.getWidth(),videoCoder.getHeight());
byte[] rawData = new byte[pic.getSize()]; //pic is a IvideoPicture
decoded from incoming video packet, contains data of type YUV420P
pic.get(0, rawData, 0, pic.getSize());
jpegPict.put(rawData, 0, 0, rawData.length);
jpegPict.setComplete(true, IPixelFormat.Type.RGB24,videoCoder.getWidth
(), videoCoder.getHeight(),timeStamp);
byte[] jpegPicture = jpegPict.getData().getByteArray(0,jpegPict.getSize
());
try {
File f = new File("samplejpeg.jpg");
FileOutputStream fileOutputStream = new FileOutputStream(
fileOutputStream.write(jpegPicture);
fileOutputStream.flush();
} catch (IOException e) { //
e.printStackTrace();
}
It does produce a jpg image, but could not open with any picture
viewer.
any comments on both issues.
also can you explain the IVideoPicture.put() and IVideoPicture.get()
method signature.
i have put my source code here for your ref.
http://pastebin.com/m381006ed