Opened 21 months ago

Last modified 14 months ago

#9080 open defect

RTP SSRC constrained to INT_MIN and INT_MAX vice 0 and UINT_MAX

Reported by: Joe Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: rtp
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: When starting an SRTP stream with a value larger than INT_MAX the following error is encountered:

Value 3322661914.000000 for parameter 'ssrc' out of range [-2.14748e+09 - 2.14748e+09]

It is my understanding from RFC 3550 SSRC should be a random 232-1 integer.

How to reproduce:

Attempt to start an SRTP stream with a uint32 larger than 2.14748e+09. Following is a report from a failed execution.

ffmpeg started on 2021-01-25 at 13:35:42
Report written to "ffmpeg-20210125-133542.log"
Log level: 48
Command line:
/usr/local/bin/ffmpeg -report -rtsp_transport tcp -r 30 -i rtsp://user:password@10.0.1.234:554/ch01/0 -an -sn -dn -codec:v libx264 -pix_fmt yuvj420p -f rawvideo -profile:v main -level:v 4.0 -vf "scale=1280:720" -b:v 299k -payload_type 99 -ssrc 3810690864 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params sVm3yOQYXeY6m658N389iLFpGtJ9c5Y62LTH5CPQ "srtp://10.0.1.210:63959?rtcpport=63959&localrtcpport=63959&pkt_size=1378"
ffmpeg version N-100810-g12c8aeb2b8 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-libx265 --enable-libxml2 --enable-libx264 --enable-shared --enable-vaapi
  libavutil      56. 63.101 / 56. 63.101
  libavcodec     58.118.100 / 58.118.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 97.100 /  7. 97.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '30'.
Reading option '-i' ... matched as input url with argument 'rtsp://admin:admin@10.0.1.234:554/ch01/0'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-sn' ... matched as option 'sn' (disable subtitle) with argument '1'.
Reading option '-dn' ... matched as option 'dn' (disable data) with argument '1'.
Reading option '-codec:v' ... matched as option 'codec' (codec name) with argument 'libx264'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuvj420p'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-profile:v' ... matched as option 'profile' (set profile) with argument 'main'.
Reading option '-level:v' ... matched as AVOption 'level:v' with argument '4.0'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'scale=1280:720'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '299k'.
Reading option '-payload_type' ... matched as AVOption 'payload_type' with argument '99'.
Reading option '-ssrc' ... matched as AVOption 'ssrc' with argument '3810690864'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtp'.
Reading option '-srtp_out_suite' ... matched as AVOption 'srtp_out_suite' with argument 'AES_CM_128_HMAC_SHA1_80'.
Reading option '-srtp_out_params' ... matched as AVOption 'srtp_out_params' with argument 'sVm3yOQYXeY6m658N389iLFpGtJ9c5Y62LTH5CPQ'.
Reading option 'srtp://10.0.1.210:63959?rtcpport=63959&localrtcpport=63959&pkt_size=1378' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://user:password@10.0.1.234:554/ch01/0.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 30.
Successfully parsed a group of options.
Opening an input file: rtsp://user:password@10.0.1.234:554/ch01/0.
[tcp @ 0x559a37570540] No default whitelist set
[tcp @ 0x559a37570540] Original list of addresses:
[tcp @ 0x559a37570540] Address 10.0.1.234 port 554
[tcp @ 0x559a37570540] Interleaved list of addresses:
[tcp @ 0x559a37570540] Address 10.0.1.234 port 554
[tcp @ 0x559a37570540] Starting connection attempt to 10.0.1.234 port 554
[tcp @ 0x559a37570540] Successfully connected to 10.0.1.234 port 554
[rtsp @ 0x559a3756d680] SDP:
v=0
o=- 3460449805 3460449805 IN IP4 10.0.1.234
c=IN IP4 10.0.1.234
t=0 0
m=video 0 RTP/AVP 96
a=control:trackID=0
a=rtpmap:96 H264/90000
a=x-dimensions:1920,1080
a=framerate:30
a=bitrate:4096
a=fmtp:96 packetization-mode=1;profile-level-id=420029;sprop-parameter-sets=Z01AKJWgHgCJ+WbAQA==,aO48gA==
a=recvonly

[rtsp @ 0x559a3756d680] video codec set to: h264
[rtsp @ 0x559a3756d680] RTP Packetization Mode: 1
[rtsp @ 0x559a3756d680] RTP Profile IDC: 42 Profile IOP: 0 Level: 29
[rtsp @ 0x559a3756d680] Extradata set to 0x559a37573040 (size: 25)
[rtsp @ 0x559a3756d680] setting jitter buffer size to 0
[rtsp @ 0x559a3756d680] hello state=0
[h264 @ 0x559a37572c00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] Format yuvj420p chosen by get_format().
[h264 @ 0x559a37572c00] Reinit context to 1920x1088, pix_fmt: yuvj420p
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37572c00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[h264 @ 0x559a37572c00] unknown SEI type 240
[rtsp @ 0x559a3756d680] All info found
[rtsp @ 0x559a3756d680] Setting avg frame rate based on r frame rate
Input #0, rtsp, from 'rtsp://user:password@10.0.1.234:554/ch01/0':
  Duration: N/A, start: 0.033000, bitrate: N/A
    Stream #0:0, 28, 1/90000: Video: h264 (Main), yuvj420p(pc, progressive), 1920x1080, 30.30 fps, 30.30 tbr, 90k tbn, 180k tbc
Successfully opened the file.
Parsing a group of options: output url srtp://10.0.1.210:63959?rtcpport=63959&localrtcpport=63959&pkt_size=1378.
Applying option an (disable audio) with argument 1.
Applying option sn (disable subtitle) with argument 1.
Applying option dn (disable data) with argument 1.
Applying option codec:v (codec name) with argument libx264.
Applying option pix_fmt (set pixel format) with argument yuvj420p.
Applying option f (force format) with argument rawvideo.
Applying option profile:v (set profile) with argument main.
Applying option vf (set video filters) with argument scale=1280:720.
Applying option b:v (video bitrate (please use -b:v)) with argument 299k.
Applying option f (force format) with argument rtp.
Successfully parsed a group of options.
Opening an output file: srtp://10.0.1.210:63959?rtcpport=63959&localrtcpport=63959&pkt_size=1378.
[srtp @ 0x559a3758ebc0] No default whitelist set
[rtp @ 0x559a376e8180] No default whitelist set
[udp @ 0x559a3758e400] No default whitelist set
[udp @ 0x559a375ac180] No default whitelist set
Successfully opened the file.
detected 4 logical cores
[h264 @ 0x559a37594480] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x559a37594480] nal_unit_type: 8(PPS), nal_ref_idc: 3
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x559a37594480] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x559a37594480] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x559a37594480] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a37594480] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x559a37594480] unknown SEI type 240
[h264 @ 0x559a37594480] Format yuvj420p chosen by get_format().
[h264 @ 0x559a37594480] Reinit context to 1920x1088, pix_fmt: yuvj420p
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x559a3769e400] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a3769e400] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a3769e400] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a3769e400] unknown SEI type 240
[h264 @ 0x559a3769e400] unknown SEI type 240
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x559a376a5740] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a376a5740] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a376a5740] unknown SEI type 240
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x559a376aa100] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a376aa100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a376aa100] unknown SEI type 240
[h264 @ 0x559a376db300] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x559a376db300] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 0x559a376db300] unknown SEI type 240
[Parsed_scale_0 @ 0x559a376a4f80] Setting 'w' to value '1280'
[Parsed_scale_0 @ 0x559a376a4f80] Setting 'h' to value '720'
[Parsed_scale_0 @ 0x559a376a4f80] Setting 'flags' to value 'bicubic'
[Parsed_scale_0 @ 0x559a376a4f80] w:1280 h:720 flags:'bicubic' interl:0
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] Setting 'video_size' to value '1920x1080'
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] Setting 'pix_fmt' to value '12'
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] Setting 'time_base' to value '1/30'
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] Setting 'frame_rate' to value '30/1'
[graph 0 input from stream 0:0 @ 0x559a3769c8c0] w:1920 h:1080 pixfmt:yuvj420p tb:1/30 fr:30/1 sar:0/1
[format @ 0x559a37a33280] Setting 'pix_fmts' to value 'yuvj420p'
[AVFilterGraph @ 0x559a3758f640] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[swscaler @ 0x559a37a35740] deprecated pixel format used, make sure you did set range correctly
[Parsed_scale_0 @ 0x559a376a4f80] w:1920 h:1080 fmt:yuvj420p sar:0/1 -> w:1280 h:720 fmt:yuvj420p sar:0/1 flags:0x4
[libx264 @ 0x559a37590180] using mv_range_thread = 56
[libx264 @ 0x559a37590180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x559a37590180] profile Main, level 4.0
[RTP muxer @ 0x559a376ad900] Value 3810690864.000000 for parameter 'ssrc' out of range [-2.14748e+09 - 2.14748e+09]
[RTP muxer @ 0x559a376ad900] Error setting option ssrc to value 3810690864.
Could not write header for output file #0 (incorrect codec parameters ?): Numerical result out of range
Error initializing output stream 0:0 -- 
[AVIOContext @ 0x559a3758c740] Statistics: 0 seeks, 0 writeouts
[libx264 @ 0x559a37590180] final ratefactor: 40.39
Conversion failed!

Change History (2)

comment:1 by Carl Eugen Hoyos, 21 months ago

Component: avutilavformat
Keywords: rtp added

comment:2 by Balling, 14 months ago

Status: newopen

That is just a bug here... https://github.com/FFmpeg/FFmpeg/blob/bc70684e74a185d7b80c8b80bdedda659cb581b8/libavformat/rtpenc.c#L34

It should be AV_OPT_TYPE_CONST and be from 0 to UINT_MAX.

Note: See TracTickets for help on using tickets.