bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.53k stars 1.58k forks source link

How to use AMD for GPU acceleration #2005

Open lvzhouzhijun opened 1 year ago

saudet commented 1 year ago

We can usually use the OpenCL kernels for that.

lvzhouzhijun commented 1 year ago

为此,我们通常可以使用 OpenCL 内核。

Is there a sample demo

saudet commented 1 year ago

Sure, this sample code uses UMat, so it should work with OpenCL: https://github.com/bytedeco/javacv/blob/master/samples/LBFFacemarkExampleWithVideo.java

lvzhouzhijun commented 1 year ago

当然,此示例代码使用 UMat,因此它应该适用于 OpenCL: https: //github.com/bytedeco/javacv/blob/master/samples/LBFFacemarkExampleWithVideo.java

Okay, thank you. I think I may have another problem that I need to trouble you with public static void main(String[] args) throws Exception { String url = "rtsp://admin:admin12345@192.168.0.212:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif"; String output = "rtmp://192.168.0.111:11935/live/livestream"; FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(url); try { grabber.start(); // 设置帧率、分辨率等参数,具体参数根据需要自行更改 FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(output, grabber.getImageWidth(), grabber.getImageHeight(), grabber.getAudioChannels()); recorder.setInterleaved(true); recorder.setVideoOption("tune", "zerolatency"); recorder.setVideoOption("preset", "ultrafast"); recorder.setVideoOption("crf", "25"); recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); recorder.setFormat("flv"); recorder.setFrameRate(grabber.getFrameRate()); recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); recorder.start(); Frame frame; while ((frame = grabber.grabImage()) != null) { recorder.record(frame); } recorder.stop(); } finally { grabber.stop(); } }

The above is my sample code

The above is my sample code, but during the streaming process, there was an output error in the middle of the day. I don't know how to solve it. I would like to ask you image