Hello,
I’m working with OpenCV 4.5 on Jetson Nano 2GB.
I need to record video from my webcam and save it to .mov or .mp4 ( I use cv::VideoWriter), the problem is that I do not know which encoding to use, while I tried a variety of fourcc-s ( like “mp4v”, “h264”, “avc1”) all of them generate a drop of fps (from 25 to 8 ) with resolution 1280x720. If I resize to a smaller size, it’s work’s better but I can’t go any lower.
So I thought about two solutions:
- Saving raw frames and encoding them only when a user would like to download recordings.
- Use some faster encoding
But I have no idea how to do that, I could only try different combinations for the whole day and I found nearly nothing!
At first, I thought it’s an OpenCV problem so askt on their forum but was redirected here :P
Thay suggested to me there that as OpenCV uses FFmpeg in the background it’s maybe a problem with my installation of it - when I set encoding to H264 (which should be supported by Jetson) it doesn’t use HW encoders or GPU at all - I used jtop to check that. It seems CPU only. Is there a way to install FFmpeg in a way that uses build-in encoding via VideoWriter?
I found a NvAPI example that does that using HW encoders, but that API is not really a thing that I would like to work with unless there’s no other choice :( , I tried to execute that example on some files saved from OpenCV (that go to my first idea) that maybe I could save my video somehow raw and then encode using that example - but I don’t know how to save the video without encoding at all. I tried anyway with a few fourcc-s, but it’s either not allowed in the example or I get shifted video :
I had issues with video reading speed so I’m not using VideoCapture but NvAPI and I get cv::Mat from it. [Check Here]