[FFmpeg-user] RTSP stream fps 29.97 instead of 30
Mark Thompson
sw at jkqxz.net
Thu Oct 5 00:20:25 EEST 2017
On 03/10/17 21:22, Jonathan Viney wrote:
> On Tue, Oct 3, 2017 at 1:56 PM, Mark Thompson <sw at jkqxz.net> wrote:
>
>> On 03/10/17 00:56, Jonathan Viney wrote:
>>> Hi,
>>>
>>> I am pulling an RTSP stream from an Axis 4K IP camera. The stream from
>> the
>>> camera is 30fps, but the resulting stream from ffmpeg is 29.97fps. Here
>> is
>>> the command:
>>>
>>> ffmpeg -rtsp_transport tcp -i rtsp://10.9.9.1:554/axis-media/media.amp
>>> -loglevel debug
>>>
>>> The rtsp log shows a framerate of 30:
>>>
>>> a=framerate:30.000000
>>>
>>> The full log output is below. Is there a way to force the framerate to 30
>>> fps?
>>>
>>> This video undergoes a second pass where it gets re-encoded, so we could
>>> adjust the frame rate there if necessary. But it would be preferable for
>> it
>>> to be right at this step.
>>>
>>> ...
>>> [rtsp @ 0x40d0d80] SDP:
>>> v=0
>>> o=- 8374289283112756277 1 IN IP4 10.9.9.1
>>> s=Session streamed with GStreamer
>>> i=rtsp-server
>>> t=0 0
>>> a=tool:GStreamer
>>> a=type:broadcast
>>> a=range:npt=now-
>>> a=control:rtsp://10.9.9.1:554/axis-media/media.amp
>>> m=video 0 RTP/AVP 96
>>> c=IN IP4 0.0.0.0
>>> b=AS:240000
>>> a=rtpmap:96 H264/90000
>>> a=fmtp:96
>>> packetization-mode=1;profile-level-id=640033;sprop-
>> parameter-sets=Z2QAM6w0yAPABD/8BbgICAoAAAfSAAHUwdDAAGP/
>> gAAMf+Nd5caGAAMf/AAAY/8a7y4b04A=,aO48MA==
>>
>> This SPS in the SDP decodes with:
>>
>> @126 VUI: timing_info_present_flag 1 (
>> 1)
>> @127 VUI: num_units_in_tick
>> 00000000000000000000001111101001 (1001)
>> @159 VUI: time_scale
>> 00000000000000001110101001100000 (60000)
>> @191 VUI: fixed_frame_rate_flag 1 (
>> 1)
>>
>> That is, the H.264 stream indeed has a fixed framerate of 60000/1001/2 ~
>> 29.97fps, and that is what ffmpeg is reading - the RTSP layer is likely
>> lying about it. (You may be able to count frames to check that.)
>>
>> If you want an exactly 30fps output then you should tell the camera to
>> generate a 30fps stream rather than the 30000/1001fps it currently is.
>>
>> - Mark
>>
>
> Thanks Mark. That's interesting, I'll see if there is a way to adjust the
> stream from the camera.
>
> How did you decode the data from the sprop-parameter-sets value?
It's just the SPS and PPS base64 coded: decode the base64, add start codes, feed it to any H.264 stream parser.
- Mark
More information about the ffmpeg-user
mailing list