How to record the 4k video in real time?

hi contributors.
when i write a 4k (3840, 2160) img to videowriter,it takes almost 100ms, this is too slow for me .
and i have tried to do the same things in cpp language, it just faster a little.

these recent days ,i find so many placese, i can even not find a similar case like “record 4k video in real time or some videowriter acceleration or some thing else”

so i have no idea but write the thing here hope someone could help me.
because my demand is to record multi-4k camera video.
100ms cause it doesnt work in even one 4k camera.

by the way, i notice the cheese on ubuntu make 4k record possible. and the file record is too small (30M file in 10seconds, videowriter mp4v_fourcc takes 200M+)
but i cant find its encoder function to help me.

so hope you guys can help me do this things in a effcient and easy way.

What is the source of the video rtsp with cv::VideoCapture? What processing are you performing on it? What format do you need to save it in, that is if its h264 over rtsp will raw h264 do or do you need to put it in a container formate like mp4.

hi, cudawarped.thank you for your attention.

  1. source is the /dev/video0
    2.no any process.i just test the time of video.write(img) one sentence.
    3.output.mp4 with the mp4v fourcc .

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.

thank you ! respect to you

Just for info, cv::cudacodec::VideoWriter has been fixed and you should be able to use to write to raw .h264 and .hevc files if you have an Nvidia GPU. See here for an example.