Opened 7 years ago
Last modified 6 years ago
#7178 new defect
RTSP framerate reported by camera is ignored
Reported by: | RomanVega | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I'm using ffmpeg to copy from an RTSP stream into a .ts file and it incorrectly reports the source fps, then copies this incorrect value into the output.
./ffmpeg -rtsp_transport tcp -use_wallclock_as_timestamps 1 -i 'rtsp://<user>:<pw>@<ip>/MediaInput/h264' -c:v copy /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 Input #0, rtsp, from 'rtsp://<user>:<pw>@<ip>/MediaInput/h264': Metadata: title : Media Presentation Duration: N/A, start: 1525193769.927267, bitrate: N/A Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], 15 fps, 30 tbr, 90k tbn, 30 tbc Output #0, mpegts, to '/tmp/output.ts': Metadata: title : Media Presentation encoder : Lavf58.13.100 Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 15 fps, 30 tbr, 90k tbn, 90k tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help
This is reading from a Panasonic WV-SFV110 IP camera which I configured through its web UI to output at 10fps. I tried other fps too but ffmpeg always reports 15fps. Looking at the output file, it does in fact contain the correct number of frames each second as configured on the camera -- confirmed by filming a stopwatch, running the above command, then splitting into individual frames with ffmpeg and manually checking.
Running a Wireshark capture, the camera is sending an SDP packet containing '..a=framerate:10..'. I believe this should be handled in some way here. I'd have a stab at implementing it myself but I can't figure out where the default 15 comes from or if I'm missing the point entirely.
I also ran against a Cisco 3050 IP camera and I get the same results.
FWIW a similar openRTSP command reads the correct framerate from the camera and puts it into the output file.
Using the -r option doesn't seem to help.
Change History (13)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
As requested:
./ffmpeg -i /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 Input #0, mpegts, from '/tmp/output.ts': Duration: 00:00:10.19, start: 1.400000, bitrate: 773 kb/s Program 1 Metadata: service_name : Media Presentation service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], 15 fps, 29.67 tbr, 90k tbn, 30 tbc At least one output file must be specified
comment:3 by , 7 years ago
Please also provide the complete, uncut console output for the original command, what you posted looks incomplete.
comment:4 by , 7 years ago
The only lines I didn't include were after it started running and I pressed q to stop. For completeness, here are those two extra lines:
frame= 77 fps= 28 q=-1.0 Lsize= 357kB time=00:00:03.83 bitrate= 762.9kbits/s speed= 1.4x video:321kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 11.077188%
I also redacted the username, password and IP address for security reasons.
comment:6 by , 7 years ago
Ah I see, perhaps you were wondering about that fps figure. Here's the last two lines after a longer run:
frame= 612 fps= 10 q=-1.0 Lsize= 31067kB time=00:01:01.07 bitrate=4167.1kbits/s speed=1.04x video:28749kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.063131%
comment:8 by , 7 years ago
I still see the same issue.
I added in -use_wallclock_as_timestamps 1
to eliminate the DTS errors seen below.
./ffmpeg -rtsp_transport tcp -i 'rtsp://<user>:<pw>@<ip>/MediaInput/h264' -c:v copy /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 Input #0, rtsp, from 'rtsp://<user>:<pw>@<ip>/MediaInput/h264': Metadata: title : Media Presentation Duration: N/A, start: 0.633333, bitrate: N/A Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], 15 fps, 10 tbr, 90k tbn, 30 tbc Output #0, mpegts, to '/tmp/output.ts': Metadata: title : Media Presentation encoder : Lavf58.13.100 Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], q=2-31, 15 fps, 10 tbr, 90k tbn, 90k tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 0, current: -48000; changing to 1. This may result in incorrect timestamps in the output file. [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 1, current: -39000; changing to 2. This may result in incorrect timestamps in the output file. [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 2, current: -30000; changing to 3. This may result in incorrect timestamps in the output file. [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 3, current: -21000; changing to 4. This may result in incorrect timestamps in the output file. [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 4, current: -12000; changing to 5. This may result in incorrect timestamps in the output file. [mpegts @ 0x2f595c0] Non-monotonous DTS in output stream 0:0; previous: 5, current: -3000; changing to 6. This may result in incorrect timestamps in the output file. frame= 622 fps= 10 q=-1.0 Lsize= 31783kB time=00:01:01.46 bitrate=4235.8kbits/s speed=1.03x video:29411kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.062655%
./ffmpeg -i /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 [mpegts @ 0x2a40280] DTS discontinuity in stream 0: packet 6 with DTS 126006, packet 7 with DTS 132000 Input #0, mpegts, from '/tmp/output.ts': Duration: 00:01:01.50, start: 1.400000, bitrate: 4233 kb/s Program 1 Metadata: service_name : Media Presentation service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], 15 fps, 30 tbr, 90k tbn, 30 tbc At least one output file must be specified
comment:10 by , 7 years ago
Increasing probesize
and analyzeduration
to 10x the default doesn't seem to make any difference. I also tried 100x.
./ffmpeg -rtsp_transport tcp -probesize 50000000 -analyzeduration 50000000 -i 'rtsp://<user>:<pw>@<ip>/MediaInput/h264' -c:v copy /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 Input #0, rtsp, from 'rtsp://<user>:<pw>@<ip>/MediaInput/h264': Metadata: title : Media Presentation Duration: N/A, start: 0.633333, bitrate: N/A Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], 15 fps, 10 tbr, 90k tbn, 30 tbc Output #0, mpegts, to '/tmp/output.ts': Metadata: title : Media Presentation encoder : Lavf58.13.100 Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], q=2-31, 15 fps, 10 tbr, 90k tbn, 90k tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 0, current: -48000; changing to 1. This may result in incorrect timestamps in the output file. [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 1, current: -39000; changing to 2. This may result in incorrect timestamps in the output file. [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 2, current: -30000; changing to 3. This may result in incorrect timestamps in the output file. [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 3, current: -21000; changing to 4. This may result in incorrect timestamps in the output file. [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 4, current: -12000; changing to 5. This may result in incorrect timestamps in the output file. [mpegts @ 0x24fcf40] Non-monotonous DTS in output stream 0:0; previous: 5, current: -3000; changing to 6. This may result in incorrect timestamps in the output file. frame= 614 fps= 10 q=-1.0 Lsize= 33244kB time=00:01:00.66 bitrate=4489.1kbits/s speed=1.04x video:30767kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.053100%
./ffmpeg -probesize 50000000 -analyzeduration 50000000 -i /tmp/output.ts ffmpeg version N-90820-gd06b01f Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-nonfree libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 19.100 / 7. 19.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 [mpegts @ 0x21ca440] DTS discontinuity in stream 0: packet 6 with DTS 126006, packet 7 with DTS 132000 Input #0, mpegts, from '/tmp/output.ts': Duration: 00:01:00.70, start: 1.400000, bitrate: 4486 kb/s Program 1 Metadata: service_name : Media Presentation service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 1280x960 [SAR 1:1 DAR 4:3], 15 fps, 30 tbr, 90k tbn, 30 tbc At least one output file must be specified
comment:11 by , 7 years ago
Does anyone have any input on my ideas looking at the code? i.e. where does the detected 15 fps come from, and could I fix this by adding something to parse the SDP header better?
comment:12 by , 6 years ago
the 15fps is calculated.
SDP RFC defines the framerate as ”maximum framerate", not the average frame-rate.
May I ask why do you need the frame rate ?
comment:13 by , 6 years ago
the 15fps is calculated
Can you give me some pointers as to where in the code? The calculation doesn't seem correct in this case. The camera is outputting at a steady 10fps.
May I ask why do you need the frame rate ?
To estimate the frame timestamps downstream in legacy code that doesn't have the ability to read that information directly from the stream.
Console output looks incomplete, please also provide
ffmpeg -i output.ts
output.