ngraziano / SharpRTSP

A RTSP handling library
Other
557 stars 182 forks source link

The frame rate of the recorded video becomes high. #39

Closed komei-m closed 6 years ago

komei-m commented 6 years ago

Hello. I am using the RTSP Client Example to record the video of the network camera. .264 file is generated, but the speed of the video is about 30 times. Camera images are output at 1 fps, but in the generated file it is 25 to 30 fps. Do you know what is wrong?

RogerHardiman commented 6 years ago

Can you make the camera available online so we can take a look? The SPS and PPS store the video frame rate which is used in .264 files so maybe the camera is sending an invalid SPS and PPS.

komei-m commented 6 years ago

Thank you for a wonderful suggestion. But, the camera is borrowed from "Axis" using "Axis Virtual Loan Tool". I am unable to show you the camera because it is limited by the contract.

Is the camera setting incorrect? If the camera settings are bad, I should not ask questions here.

RogerHardiman commented 6 years ago

Do you still have any of the .264 files you could upload?

komei-m commented 6 years ago

yes, I have. This is a file that recorded video outputted at 1 fps from the camera for about 90 seconds. When I played this .264 file on VLC, it ended in about 3 seconds.

Also, I encoded this .264 file into mp4 with ffmpeg. When no option : Same as when playing with vlc. When "-r 1" add : I got a video with 1 fps and 90 seconds.

rtsp_capture_20180705_180702.zip

RogerHardiman commented 6 years ago

Thank you for the video clip. When I play the file with 'ffplay' it says your .264 file is 25fps. _Input #0, h264, from 'rtsp_capture_20180705_180702.264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 800x450 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 50 tbc

This frame rate is what is stored in the .264 file in the first block of data, called the SPS and PPS. The SPS and PPS contain various parameters about the video including the width, height, aspect ratio (the SAR/DAR values) and the Frames Per Second.

It is the Axis camera that generates the SPS and PPS. It stores them in the SDP data which is part of the RTSP DESCRIBE Command. SharpRTSP just writes the SPS and PPS to the disk ready for things like 'ffplay' to use

So you have found a bug in the Axis camera.

komei-m commented 6 years ago

Thank you very much. I will contact Axis support.