type:{[VIDEO]}, timestamp:{1200000}, h:{360}, w:{640}, buff:{1}, channel:{1}
FFmpegFrameGrabber grabber =
new FFmpegFrameGrabber(
"/home/tanxw/Documents/trtc_6.5.40/examples/resource/ruguo-640x360.mp4");
grabber.setVideoCodec(avcodec.AV_CODEC_ID_H264);
grabber.setPixelFormat(avutil.AV_PIX_FMT_YUVA420P);
grabber.start();
frame = grabber.grab();
var buff = (ByteBuffer) frame.image[0];
limit:230400 capacity: 345600? why? Why the data is incomplete Only Y
The limit is set with whatever stride we get, but in the case of planar formats like this, it looks like we only get a value for the first plane... Just ignore it, use capacity.
Thank you for your answer
var buff = (ByteBuffer) frame.image[0];
var byteBuff = new byte[buff.capacity()];
buff.limit(buff.capacity()); // edit limit to capacity size
buff.get(byteBuff, buff.position(), buff.capacity());
buff.rewind();
Problem solved
Most helpful comment
Thank you for your answer
var buff = (ByteBuffer) frame.image[0];
var byteBuff = new byte[buff.capacity()];
buff.limit(buff.capacity()); // edit limit to capacity size
buff.get(byteBuff, buff.position(), buff.capacity());
buff.rewind();
Problem solved