Java Code Examples for org.bytedeco.javacpp.avutil.AVFrame#data()

The following examples show how to use org.bytedeco.javacpp.avutil.AVFrame#data() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FFmpegVideoImageGrabber.java    From easyCV with Apache License 2.0 6 votes vote down vote up
@Override
protected ByteBuffer saveFrame(AVFrame pFrame, int width, int height) {
	BytePointer data = pFrame.data(0);
	int size = width * height * 3;
	ByteBuffer buf = data.position(0).limit(size).asBuffer();
	if(viwer==null) {
		viwer=new ImageViewer(width,height, BufferedImage.TYPE_3BYTE_BGR);
	}else {
		if(index==0) {
			index++;
			viwer.setSize(width, height);
		}
	}
	
	viwer.show(buf,width,height);
	return buf;
}
 
Example 2
Source File: FFmpeg4VideoImageGrabber.java    From easyCV with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] saveFrame(AVFrame frameRGB, int width, int height) {
	BytePointer data = frameRGB.data(0);
	int size = width * height * 3;
	//复制虚拟机外内存数据到java虚拟机中,因为这个方法之后会清理内存
	byte[] bytes=new byte[size];
	data.position(0).limit(size).get(bytes,0,size);
	return bytes;
}
 
Example 3
Source File: FFmpegVideoImageGrabber.java    From easyCV with Apache License 2.0 5 votes vote down vote up
@Override
protected ByteBuffer saveFrame(AVFrame pFrame, int width, int height){
	BytePointer data = pFrame.data(0);
	int size = width * height * 3;
	ByteBuffer buf = data.position(0).limit(size).asByteBuffer();
	return buf;
}
 
Example 4
Source File: TestFFmpeg.java    From easyCV with Apache License 2.0 5 votes vote down vote up
/**
	 * 保存帧
	 * @param pFrame
	 * @param width
	 * @param height
	 * @return
	 * @throws IOException
	 */
	private static ByteBuffer saveFrame(AVFrame pFrame, int width, int height) throws IOException {
//		byte[] arr=new byte[width*height*3];
//		BytePointer data = pFrame.data(0).get(arr);
//		JavaImgConverter.viewBGR(width, height,ByteBuffer.wrap(arr));
		BytePointer data=pFrame.data(0);
		int size=width*height*3;
		ByteBuffer buf=data.position(0).limit(size).asBuffer();
		return buf;
	}
 
Example 5
Source File: TestFFmpeg.java    From easyCV with Apache License 2.0 4 votes vote down vote up
public static BufferedImage frame2BufferImage(AVFrame pFrame, int width, int height) {
	BytePointer data=pFrame.data(0);
	int size=width*height*3;
	ByteBuffer buf=data.position(0).limit(size).asBuffer();
	return JavaImgConverter.BGR2BufferedImage(buf, width, height);
}
 
Example 6
Source File: FFmpegVideoImageGrabber.java    From easyCV with Apache License 2.0 3 votes vote down vote up
/**
 * bgr图像帧转BufferedImage图片
 * 
 * @param pFrame
 *            -bgr图像帧
 * @param width
 *            -宽度
 * @param height
 *            -高度
 * @return
 */
protected BufferedImage frame2BufferImage(AVFrame pFrame, int width, int height) {
	BytePointer data = pFrame.data(0);
	int size = width * height * 3;
	ByteBuffer buf = data.position(0).limit(size).asBuffer();
	return JavaImgConverter.BGR2BufferedImage(buf, width, height);
}