[FFmpeg-user] SRTP fails to decrypt video

Mads von Qualen mads.von.qualen at systematic.com
Wed Jun 13 18:03:57 EEST 2018


I need to encrypt a MPEG-TS stream and transmit it using UDP multicast. I use FFmpeg for both sending and receiving the video and from the documentation it seems that the SRTP protocol would fit my needs.

If the receiving FFmpeg is started within a relative short time (< 1 minute) after the sending side then the video is decrypted just fine. However, if I start the receiving FFmpeg a little later then the decryption is never initialized correctly and stderr is spammed with "HMAC mismatch".

Is this a bug in FFmpeg or am I using SRTP wrong?

Below are the commands used both on the receiving and sending side.

Thanks!

/Mads

----------------------------------
Sending side command:

$ ffmpeg -re -stream_loop -1 -i sample.ts -map 0 -codec copy -f rtp_mpegts -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params AD7YTI3F3BpWusoh2x1uHUxieqcTbosTSb0yNcfg srtp://239.1.2.3:4567
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mpegts, from 'sample.ts':
  Duration: 00:02:28.18, start: 120.106733, bitrate: 5572 kb/s
  Program 1
    Stream #0:0[0x100]: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 112 kb/s
    Stream #0:2[0x102]: Data: klv (KLVA / 0x41564C4B)
[udp @ 0000000402b99360] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0000000402b99400] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Output #0, rtp_mpegts, to 'srtp://239.1.2.3:4567':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 112 kb/s
    Stream #0:2: Data: klv (KLVA / 0x41564C4B)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame=  255 fps= 30 q=-1.0 size=    5890kB time=00:00:08.57 bitrate=5626.7kbits/s speed=   1x


----------------------------------
Receiving side command:

$ ffplay -srtp_in_suite AES_CM_128_HMAC_SHA1_80 -srtp_in_params AD7YTI3F3BpWusoh2x1uHUxieqcTbosTSb0yNcfg -i srtp://239.1.2.3:4567
ffplay version 3.4.1 Copyright (c) 2003-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[udp @ 000000f23926c420] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000000f23927c6a0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
HMAC mismatch 0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
    Last message repeated 102 times
HMAC mismatch 0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
    Last message repeated 85 times
HMAC mismatch 0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
    Last message repeated 17 times
HMAC mismatch 0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
    Last message repeated 38 times
...


More information about the ffmpeg-user mailing list