Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ffmpeg for stream encryption by srtp in windows

I have been trying to make encrypted stream via ffmpeg and I´ve found srtp support in this library (ffmpeg documentation). Unfortunately, it seems that encryption doesn´t work at all. I´m using the following command to send stream:

ffmpeg -re -i "output.mpg" -vcodec libx264 -f flv "srtp://192.168.0.100:7777?srtp_out_suite=AES_CM_128_HMAC_SHA1_80&srtp_out_params=00108310518720928b30d38f41149351559761969b71d79f8218a39259a7"

and this one for stream receiving:

ffplay "srtp://192.168.0.100:7777?srtp_in_suite=AES_CM_128_HMAC_SHA1_80&srtp_in_params=00108310518720928b30d38f41149351559761969b71d79f8218a39259a7"

They work good. But, If I change the command for ffplay to this one:

ffplay udp://192.168.0.100:7777

it works too and I can watch the video. So, it means that encryption for srtp doesn´t work?

  1. Is the stream encryption by using ffmpeg possible (not only srtp)?
  2. If so, What am I doing wrong?

Thanks in advance.

An output from ffmpeg -re -i ... command is:

Input #0, mpeg, from 'outpu.mpg':
Duration: 00:03:20.01, start: 0.529089, bitrate: 475 kb/s
Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 352x288 [SAR 1:1 DAR 11:
9], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc
Stream #0:1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16p, 64 kb/s
[libx264 @ 023633e0] using SAR=1/1
[libx264 @ 023633e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 023633e0] profile High, level 1.3
[libx264 @ 023633e0] 264 - core 138 r2358 9e941d1 - H.264/MPEG-4 AVC codec - Cop
yleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deb
lock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 m
e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro
ma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i
nterlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenec
ut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=
0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'srtp://192.168.0.106:7777?srtp_out_suite=AES_CM_128_HMAC_SHA
1_80&srtp_out_params=00108310518720928b30d38f41149351559761969b71d79f8218a39259a
7':
  Metadata:
    encoder         : Lavf55.19.100
   Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 352x288
[SAR 1:1 DAR 11:9], q=-1--1, 1k tbn, 25 tbc
   Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, ster
   eo, s16p
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg1video -> libx264)
  Stream #0:1 -> #0:1 (mp2 -> libmp3lame)
Press [q] to stop, [?] for help
frame=   14 fps=0.0 q=0.0 size=       0kB time=00:00:00.13 bitrate=  23.2kbits/s
frame=   27 fps= 27 q=0.0 size=       0kB time=00:00:00.65 bitrate=   4.7kbits/s
frame=   40 fps= 26 q=0.0 size=       0kB time=00:00:01.15 bitrate=   2.7kbits/s
frame=   52 fps= 26 q=28.0 size=       3kB time=00:00:01.67 bitrate=  16.8kbits/
...

Edit:

I have tried the above ffmpeg command with srtp_out_suite=NmcxMmQ2ZjVnYjEyNmRmMTV2czY1YWR2ZjFhc2Rm, but udp stream is still playing well.

like image 247
Carrot Hunter Avatar asked Jan 29 '14 13:01

Carrot Hunter


1 Answers

Those are command-line options, not URL options.

Send:

ffmpeg -re -i input.avi -f rtp_mpegts -acodec mp3 -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz srtp://127.0.0.1:20000

Receive:

ffplay -srtp_in_suite AES_CM_128_HMAC_SHA1_80 -srtp_in_params zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz srtp://127.0.0.1:20000
like image 70
aaz Avatar answered Oct 11 '22 02:10

aaz