Discussion:
[FFmpeg-user] RTSP stream fps 29.97 instead of 30
Jonathan Viney
2017-10-02 23:56:31 UTC
Permalink
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.

Kind Regards,
-Jonathan.


ffmpeg version N-87616-g792b1629a8-static http://johnvansickle.com/ffmpeg/
Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.4.0 (Debian 6.4.0-7) 20170920
configuration: --enable-gpl --enable-version3 --enable-static
--disable-debug --disable-ffplay --disable-indev=sndio
--disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-gray --enable-libfribidi --enable-libass
--enable-libvmaf --enable-libfreetype --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-librubberband --enable-librtmp --enable-libsoxr --enable-libspeex
--enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab
--enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxvid --enable-libzimg
libavutil 55. 77.101 / 55. 77.101
libavcodec 57.106.104 / 57.106.104
libavformat 57. 82.102 / 57. 82.102
libavdevice 57. 9.101 / 57. 9.101
libavfilter 6.106.100 / 6.106.100
libswscale 4. 7.103 / 4. 7.103
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Splitting the commandline.
Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport'
with argument 'tcp'.
Reading option '-i' ... matched as input url with argument 'rtsp://
10.9.9.1:554/axis-media/media.amp'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://
10.9.9.1:554/axis-media/media.amp.
Successfully parsed a group of options.
Opening an input file: rtsp://10.9.9.1:554/axis-media/media.amp.
[tcp @ 0x40d2c00] No default whitelist set
[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==
a=control:rtsp://10.9.9.1:554/axis-media/media.amp/stream=0
a=framerate:30.000000
a=transform:1.000000,0.000000,0.000000;0.000000,1.000000,0.000000;0.000000,0.000000,1.000000

[rtsp @ 0x40d0d80] video codec set to: h264
[rtsp @ 0x40d0d80] RTP Packetization Mode: 1
[rtsp @ 0x40d0d80] RTP Profile IDC: 64 Profile IOP: 0 Level: 33
[rtsp @ 0x40d0d80] Extradata set to 0x40d2f80 (size: 65)
[rtsp @ 0x40d0d80] setting jitter buffer size to 0
[rtsp @ 0x40d0d80] hello state=0
[h264 @ 0x40d4220] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x40d4220] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x40d4220] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x40d4220] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x40d4220] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x40d4220] Reinit context to 3840x2160, pix_fmt: yuvj420p
[h264 @ 0x40d4220] no picture
[rtsp @ 0x40d0d80] All info found
[rtsp @ 0x40d0d80] rfps: 29.250000 0.019208
[rtsp @ 0x40d0d80] rfps: 29.333333 0.015021
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.416667 0.011348
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.500000 0.008189
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.583333 0.005544
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.666667 0.003414
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.750000 0.001797
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.833333 0.000695
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.916667 0.000107
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 30.000000 0.000033
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 60.000000 0.000130
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 120.000000 0.000522
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 240.000000 0.002087
Last message repeated 1 times
[rtsp @ 0x40d0d80] rfps: 29.970030 0.000000
[rtsp @ 0x40d0d80] rfps: 59.940060 0.000000
Input #0, rtsp, from 'rtsp://10.9.9.1:554/axis-media/media.amp':
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
Duration: N/A, start: 0.033367, bitrate: N/A
Stream #0:0, 23, 1/90000: Video: h264 (High), 1 reference frame,
yuvj420p(pc, bt709, progressive, left), 3840x2160 [SAR 1:1 DAR 16:9], 0/1,
29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Successfully opened the file.
At least one output file must be specified
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subjec
Mark Thompson
2017-10-03 00:56:53 UTC
Permalink
Post by Jonathan Viney
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
ffmpeg -rtsp_transport tcp -i rtsp://10.9.9.1:554/axis-media/media.amp
-loglevel debug
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.
...
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
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffm
Jonathan Viney
2017-10-03 20:22:56 UTC
Permalink
Post by Jonathan Viney
Post by Jonathan Viney
Hi,
I am pulling an RTSP stream from an Axis 4K IP camera. The stream from
the
Post by Jonathan Viney
camera is 30fps, but the resulting stream from ffmpeg is 29.97fps. Here
is
Post by Jonathan Viney
ffmpeg -rtsp_transport tcp -i rtsp://10.9.9.1:554/axis-media/media.amp
-loglevel debug
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
Post by Jonathan Viney
to be right at this step.
...
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==
@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?

Thanks,
-Jonathan.
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscrib
Mark Thompson
2017-10-04 21:20:25 UTC
Permalink
Post by Jonathan Viney
Post by Jonathan Viney
Post by Jonathan Viney
Hi,
I am pulling an RTSP stream from an Axis 4K IP camera. The stream from
the
Post by Jonathan Viney
camera is 30fps, but the resulting stream from ffmpeg is 29.97fps. Here
is
Post by Jonathan Viney
ffmpeg -rtsp_transport tcp -i rtsp://10.9.9.1:554/axis-media/media.amp
-loglevel debug
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
Post by Jonathan Viney
to be right at this step.
...
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==
@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
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject
Carl Eugen Hoyos
2017-10-05 06:48:34 UTC
Permalink
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
parameter-sets=Z2QAM6w0yAPABD/8BbgICAoAAAfSAAHUwdDAAGP/
gAAMf+Nd5caGAAMf/AAAY/8a7y4b04A=,aO48MA==
@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.
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.
My question would have been:
Where can I find any H.264 stream parser?

Thank you, Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpe
Mark Thompson
2017-10-05 10:28:31 UTC
Permalink
Post by Carl Eugen Hoyos
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
parameter-sets=Z2QAM6w0yAPABD/8BbgICAoAAAfSAAHUwdDAAGP/
gAAMf+Nd5caGAAMf/AAAY/8a7y4b04A=,aO48MA==
@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.
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.
Where can I find any H.264 stream parser?
<http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/216249.html> - the trace_headers filter will generate traces like this.

Unfortunately that doesn't actually work for the stream fragment here because outer layers in ffmpeg don't like a stream containing no slices - I instead used the JM reference decoder in this case, which is happy to parse an isolated NAL unit.

- Mark
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-req
Carl Eugen Hoyos
2017-10-05 10:31:00 UTC
Permalink
Post by Mark Thompson
I instead used the JM reference decoder in this case, which
is happy to parse an isolated NAL unit.
Thank you!

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg
Jonathan Viney
2017-10-30 03:56:03 UTC
Permalink
Post by Carl Eugen Hoyos
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
parameter-sets=Z2QAM6w0yAPABD/8BbgICAoAAAfSAAHUwdDAAGP/
gAAMf+Nd5caGAAMf/AAAY/8a7y4b04A=,aO48MA==
@126 VUI: timing_info_present_flag 1
(
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
1)
@127 VUI: num_units_in_tick
00000000000000000000001111101001 (1001)
@159 VUI: time_scale
00000000000000001110101001100000 (60000)
@191 VUI: fixed_frame_rate_flag 1
(
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
1)
That is, the H.264 stream indeed has a fixed framerate of 60000/1001/2
~
Post by Mark Thompson
Post by Jonathan Viney
Post by Jonathan Viney
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.
Thanks Mark. That's interesting, I'll see if there is a way to adjust
the
Post by Mark Thompson
Post by Jonathan Viney
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.
Where can I find any H.264 stream parser?
In case anyone is interested, I used h264_analyze from
https://github.com/aizvorski/h264bitstream to parse the NAL units.

ffmpeg -rtsp_transport tcp -i rtsp://10.9.9.1:554/axis-media/media.amp
-loglevel
debug out.mp4
ffmpeg -i out.mp4 -c copy -vbsf h264_mp4toannexb -an -y out.mp4.h264
h264_analyze out.mp4.h264

The nal_unit_type of 7 is the SPS, and contains the values mentioned by
Mark.

Thanks,
-Jonathan.
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg

Continue reading on narkive:
Search results for '[FFmpeg-user] RTSP stream fps 29.97 instead of 30' (Questions and Answers)
6
replies
what is streaming multimedia?
started 2006-09-25 23:39:16 UTC
internet
Loading...