How can I stream h264 video from RTSP directly into file without encoding?

asked 2019-10-23 11:02:18 -0600

mczarnek gravatar image

I'm trying to stream h264 video from a RTSP stream and directly store it into a file and skip decoding/encoding for most frames as I need high performance and hundreds of frames per second. Though the occasional frame will likely need to be analyzed (may be able to get around this in hardware.. in which case ffmpeg instead of OpenCV would work, but ffmpeg is complicated.. would prefer to avoid). I would slightly prefer mp4, but doesn't really matter the file container being used.

I know that I can do this in ffmpeg command line like this: ffmpeg -i <rtsp url=""> -c copy -map 0 -f segment -segment_time 30000 -strftime 1 -reset_timestamps 1 -segment_format mp4 <video name="">

Is it possible to do this in openCV? Seems like if I specify the same codec as the input to be used for output that it still encodes decodes based on CPU Usage still being the same instead of just skipping decoding/encoding.

Thank you for your time!

edit retag flag offensive close merge delete

Comments

i do not think, this is an opencv question

berak gravatar imageberak ( 2019-10-23 11:09:51 -0600 )edit

It is, I would like to use OpenCV, just happen to be stating how it works in ffmpeg. I would like to do the same thing with OpenCV instead.

mczarnek gravatar imagemczarnek ( 2019-10-23 12:38:47 -0600 )edit

why would you use a mainly computer-vision library (that happens to wrap some ffmpeg functionality) for this ?

berak gravatar imageberak ( 2019-10-23 13:00:32 -0600 )edit

Feel like you haven't read the question(not that I don't appreciate the help)

Two reasons: 1) We will likely be analyzing video in the future, having the ability to do so is nice. 2) ffmpeg is a pain to setup and write compared to opencv, other than this issue.

mczarnek gravatar imagemczarnek ( 2019-10-23 13:21:19 -0600 )edit