Ahh if it wasn’t hardware you could just directly read the raw encoded data and write to disk. I have done this on Windows with a slight modification but had limited success on linux see
and
if you are interested.
Hopefully soon the cv::cudacodec::VideoWriter class will be fixed so if you have an Nvidia GPU this would be an option, however you would only be able to encode to raw h264|hevc files. To get container formats like mp4 you would have to post process the output files with FFmpeg or similar.