I currently receive and store a RTSP stream from a camera with openRTSP with a command like this:
openRTSP -4 "rtsp://192.168.41.185/rtsp_tunnel?h26x=4&line=1&inst=2" > movie.mp4
I can do the same using FFmpeg:
ffmpeg -i "rtsp://192.168.41.185/rtsp_tunnel?h26x=4&line=1&inst=2" -vcodec copy movie.mp4
The video frames from the camera are 1280x720 (H.264) at around 30 fps and have a milliseconds timestamp stamped in. When I view the movie.mp4 created by ffmpeg it looks pretty nice, the seconds stamped into the video stream seem rather accurate. On the contrary, if I view the movie.mp4 created by openRTSP, the seconds in the video timestamp last definitively longer than the ones in reality. So one second on video could last two seconds in reality. I made several tests, and it is not an issue of network performance or of handling the messages received from the camera. The reason seems to be the part where the messages are encoded into this MP4 container.
Is FFmpeg so much faster doing this than openRTSP?
Can I optimize the MP4 encoding in openRTSP somehow?
Okay, it is not a performance issue, but rather in issue that openRTSP is not able to detect the correct frame rate from the RTSP stream. I recorded exactly 60 seconds, and as suggested, I used
ffprobe
to get more information about the bitstream:Two things are wrong:
For issue #1: That may be my fault. I should have manually specified the frame rate as openRTSP doesn't get it from the stream. I should have specified the option
-f 30
.For issue #2: After giving the option
-f 30
I still get a video file with a duration of 2:00 instead 1.00. I guess that the problem is that the camera sends its data in progressive mode, and not in interlaced mode. Maybe openRTSP's default is interlaced mode. So when I double the frame rate to-f 60
everything is all right.Maybe someone can confirm my guess?