[FFmpeg-devel] avformat/librtmp : new option (swfhash and swfsize)

Sinan Aksu sinanksu at gmail.com
Sat Sep 23 23:09:52 EEST 2017


Hi,

I am not a developer, I am a user. I am trying to solve a problem that I am
experiencing myself. I need your help on this.

I am trying to record a live rtmp stream with FFmpeg. Live stream source
requires swf validation. But I have a compressed swf. FFmpeg can not find
the correct hash / size values.

For this reason, I have to manually assign these two values. In the Librtmp
library these options are available as manually adjustable. But FFmpeg does
not offer these options.

I followed these steps to add these options;

Step 1: I downloaded releases ffmpeg-snapshot.tar.bz2

Step 2: I reviewed ffmpeg \ libavformat \ rtmpproto.c.

I found these lines:
Line 109 :::     char*      swfhash;        ///< SHA256 hash of the
decompressed SWF file (32 bytes)
Line 110 :::     int        swfhash_len;    ///< length of the SHA256 hash
Line 111 :::     int        swfsize;        ///< size of the decompressed
SWF file

Line 3130 ::    {"rtmp_swfhash", "SHA256 hash of the decompressed SWF file
(32 bytes).", OFFSET(swfhash), AV_OPT_TYPE_BINARY, .flags = DEC},
Line 3131 ::    {"rtmp_swfsize", "Size of the decompressed SWF file,
required for SWFVerification.", OFFSET(swfsize), AV_OPT_TYPE_INT, {.i64 =
0}, 0, INT_MAX, DEC},


Step 3: I have reviewed ffmpeg \ libavformat \ librtmp.c.
Result: There were no rtmp_swfhash and rtmp_swfsize options.
I have added the following lines:

++  char *swfhash;
++  int swfsize;

++  {"rtmp_swfhash", "SHA256 hash of the decompressed SWF file (32
bytes).", OFFSET(swfhash), AV_OPT_TYPE_BINARY, .flags = DEC},
++  {"rtmp_swfsize", "Size of the decompressed SWF file, required for
SWFVerification.", OFFSET(swfsize), AV_OPT_TYPE_INT, {.i64 = 0}, 0,
INT_MAX, DEC},

Step 4: I compiled it again on ubuntu.
Step 5: I tested it.
Result: Accepted the options. He did not make a mistake. But it did not
work. The values ​​I assign to options are not included in the rtmp package.

WHERE DO I MISTAKE? Rtmpdump packet adds many options. But sending ffmpeg
package is missing.

FFmpeg Librtmp Result

Command : ./ffmpeg -loglevel debug  -i "rtmpe://ip/xlive" -rtmp_tcurl
"rtmpe://ip/xlive" -rtmp_app xlive -rtmp_flashver "WIN 23,0,0,162"
-rtmp_swfurl "http://local/Player.swf" -rtmp_swfverify "
http://local/Player.swf" -rtmp_swfhash
"50102110f085d9284d7f069e5e3a9150e4a241d7557d6d1f9e460fdf315875c8"
-rtmp_swfsize 611197 -rtmp_pageurl "http://local/?v=139363695" -rtmp_conn
S:client -rtmp_conn S:3.1.0.10 -rtmp_conn S:en -rtmp_live live -live 1
-rtmp_playpath "raw:878162" -f flv -y aa.flv

Output Packet : RTMP_SendPacket: fd=4, size=172
  0000:  03 00 00 00 00 00 ac 14  00 00 00 00               ............
  0000:  02 00 07 63 6f 6e 6e 65  63 74 00 3f f0 00 00 00   ...connect.?....
  0010:  00 00 00 03 00 03 61 70  70 02 00 05 78 6c 69 76   ......app...xliv
  0020:  65 00 05 74 63 55 72 6c  02 00 1b 72 74 6d 70 65   e..tcUrl...rtmpe
  0030:  3a 2f 2f 39 31 2e 31 39  32 2e 38 30 2e 32 31 30   ://ip
  0040:  2f 78 6c 69 76 65 00 04  66 70 61 64 01 00 00 0c   /xlive..fpad....
  0050:  63 61 70 61 62 69 6c 69  74 69 65 73 00 40 2e 00   capabilities. at ..
  0060:  00 00 00 00 00 00 0b 61  75 64 69 6f 43 6f 64 65   .......audioCode
  0070:  63 73 00 40 a8 ee 00 00  00 00 00 00 0b 76 69 64   cs. at .........vid
  0000:  c3                                                 .
  0000:  65 6f 43 6f 64 65 63 73  00 40 6f 80 00 00 00 00   eoCodecs. at o.....
  0010:  00 00 0d 76 69 64 65 6f  46 75 6e 63 74 69 6f 6e   ...videoFunction
  0020:  00 3f f0 00 00 00 00 00  00 00 00 09               .?..........
Invoking connect


RTMPDump Librtmp Result

Command : rtmpdump --debug -r rtmpe://ip/xlive -a xlive -f WIN 23,0,0,162
-s "http://local/Player.swf" -w
50102110f085d9284d7f069e5e3a9150e4a241d7557d6d1f9e460fdf315875c8 -x 611197
-p "http://local/?v=139363695" -C S:client -C S:3.1.0.10 -C S:en --live -y
raw:"878162"


Output Packet : DEBUG2: RTMP_SendPacket: fd=328, size=373
DEBUG2:   0000:  03 00 00 00 00 01 75 14  00 00 00 00
......u.....
DEBUG2:   0000:  02 00 07 63 6f 6e 6e 65  63 74 00 3f f0 00 00 00
...connect.?....
DEBUG2:   0010:  00 00 00 03 00 03 61 70  70 02 00 05 78 6c 69 76
......app...xliv
DEBUG2:   0020:  65 00 08 66 6c 61 73 68  56 65 72 02 00 03 57 49
e..flashVer...WI
DEBUG2:   0030:  4e 00 06 73 77 66 55 72  6c 02 00 3c 68 74 74 70
N..swfUrl..<http
DEBUG2:   0040:  3a 2f 2f 73 74 72 65 61  6d 73 70 6f 72 74 33 36
://loca/Player.s
DEBUG2:   0050:  35 2e 63 6f 6d 2f 67 65  74 5a 6f 6e 65 2f 56 69
wfxxxxxxxxxxxxxx
DEBUG2:   0060:  64 65 6f 50 6c 61 79 65  72 53 70 6f 72 74 73 74
deoPlayerSportst
DEBUG2:   0070:  72 65 61 6d 2e 73 77 66  00 05 74 63 55 72 6c 02
ream.swf..tcUrl.
DEBUG2:   0000:  c3                                                 .
DEBUG2:   0000:  00 20 72 74 6d 70 65 3a  2f 2f 39 31 2e 31 39 32   .
rtmpe://ip/xxx
DEBUG2:   0010:  2e 38 30 2e 32 31 30 3a  31 39 33 35 2f 78 6c 69
/xlixxxxxxxxxxxx
DEBUG2:   0020:  76 65 00 04 66 70 61 64  01 00 00 0c 63 61 70 61
ve..fpad....capa
DEBUG2:   0030:  62 69 6c 69 74 69 65 73  00 40 6d e0 00 00 00 00
bilities. at m.....
DEBUG2:   0040:  00 00 0b 61 75 64 69 6f  43 6f 64 65 63 73 00 40
...audioCodecs.@
DEBUG2:   0050:  ab ee 00 00 00 00 00 00  0b 76 69 64 65 6f 43 6f
.........videoCo
DEBUG2:   0060:  64 65 63 73 00 40 6f 80  00 00 00 00 00 00 0d 76   decs. at o.
.......v
DEBUG2:   0070:  69 64 65 6f 46 75 6e 63  74 69 6f 6e 00 3f f0 00
ideoFunction.?..
DEBUG2:   0000:  c3                                                 .
DEBUG2:   0000:  00 00 00 00 00 00 07 70  61 67 65 55 72 6c 02 00
.......pageUrl..
DEBUG2:   0010:  2f 68 74 74 70 3a 2f 2f  73 74 72 65 61 6d 73 70   /
http://local/?v
DEBUG2:   0020:  6f 72 74 33 36 35 2e 63  6f 6d 2f 76 69 65 77 65
=xxxxxxxxxxxxxxx
DEBUG2:   0030:  72 3f 67 61 6d 65 3d 31  33 39 32 39 37 34 35 37
xxxxxxxxxxxxxxxx
DEBUG2:   0040:  00 0e 6f 62 6a 65 63 74  45 6e 63 6f 64 69 6e 67
..objectEncoding
DEBUG2:   0050:  00 40 08 00 00 00 00 00  00 00 00 09 02 00 06 63
. at .............c
DEBUG2:   0060:  6c 69 65 6e 74 02 00 08  33 2e 31 2e 30 2e 31 30
lient...3.1.0.10
DEBUG2:   0070:  02 00 02 65 6e                                     ...en
DEBUG: Invoking connect
INFO: Connected...

Thankyou...


More information about the ffmpeg-devel mailing list