javacv
javacv copied to clipboard
FFmpegFrameGrabber set Frame skipping
When using ffmpegframegrabber decoding, I want to get only one frame of data per second. I want to ask if ffmpegframegrabber provides such parameter settings. I use setframerate, but it does not work
FFmpegFrameGrabber.tryLoad();
FFmpegFrameRecorder.tryLoad();
FFmpegLogCallback.set();
System.setProperty("java.awt.headless", "false");
String url = "rtsp://admin:[email protected]/";
FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(url);
grabber.setOption("rtsp_transport", "tcp");
grabber.setOption("timeout", "2000000");
grabber.setOption("rw_timeout", "2000000");
grabber.setFrameRate(1);
grabber.setImageWidth(1920);
grabber.setImageHeight(1080);
String encodeName = "h264_nvenc";
String encodeName2 = "h264_cuvid";
// grabber.setVideoCodecName("vaapi"); System.out.println("grabber start"); grabber.start(); CanvasFrame canvasFrame = new CanvasFrame("opencvtest"); canvasFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvasFrame.setAlwaysOnTop(true); OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat(); // OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); int num = 0 ; while (true){ System.out.println(System.currentTimeMillis()/1000); Frame frame = grabber.grabImage(); canvasFrame.showImage(frame); // Thread.sleep(5000); }
We can call grabAtFrameRate() instead of grab(), if that's what your looking for?
We can call grabAtFrameRate() instead of grab(), if that's what your looking for?
grabAtFrameRate() Can't do it,It seems that I can only discard some frames manually. What I hope to achieve is that only one frame of data is returned every 25 frames, skip 24 of them. grabAtFrameRate() In, I found that he can sleep, but sleep does not get the frame data of the current time, and only gets the continuous frames before sleep.
That sounds maybe like grabKeyFrame()?
That sounds maybe like grabKeyFrame()?
Thank you very much. This function is similar to the expected work, but it cannot control the number of returned frames per second. At present, it seems that only some frames can be discarded manually
That sounds maybe like grabKeyFrame()?
Thank you very much. This function is similar to the expected work, but it cannot control the number of returned frames per second. At present, it seems that only some frames can be discarded manually
That sounds maybe like grabKeyFrame()?
I want to confirm that if you want to accelerate decoding with GPU NVIDIA graphics card, do you have to install ffmpeg and the corresponding decoder dependencies on the host computer?
I am here https://github.com/bytedeco/javacv/issues/1767 Only POM related dependencies are seen in, and the modules to be installed by the host machine are not mentioned
Can you provide a case of using GPU acceleration in the wiki
Thank you very much. This function is similar to the expected work, but it cannot control the number of returned frames per second. At present, it seems that only some frames can be discarded manually
If your stream is based on key frames, it's not possible to decode any other frames independently. However, if your stream has other kinds of frames, it might be possible to decode only some of them. @mihirbala should be able to help you with that, see issue #1832.
I want to confirm that if you want to accelerate decoding with GPU NVIDIA graphics card, do you have to install ffmpeg and the corresponding decoder dependencies on the host computer?
You only need to install the correct video driver for your GPU, and it should work out of the box by setting the right codec with setVideoCodecName() before calling start(). We do not need CUDA.
Can you provide a case of using GPU acceleration in the wiki
There's a wiki page with the names of the codecs here: https://trac.ffmpeg.org/wiki/HWAccelIntro
If you would like to have something with more details, contributions are welcome!
Duplicate of #1121