Re: [FFmpeg-user] RTMP handshaking behind a proxy
I have given this command another try on another machine today, and read a bit more about the handshaking process. It does not seem to open any other port, just exchanging specific packets on the 1935 port... So something is fishy on my redsocks configuration I suppose... Here is part of the strace command: socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 5 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.194")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(51463), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.146")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(45181), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.205")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(49529), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.119")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(33848), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.25")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(59504), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.28")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(45114), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.211")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(42766), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.169")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(43587), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.236")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(33059), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.9")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(40109), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.95")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(46689), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.16")}, 16) = 0 getsockname(5, {sa_family=AF_INET, sin_port=htons(4), sin_addr=inet_addr("192.168.0.217")}, [28->16]) = 0 close(5)= 0 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 5 fcntl(5, F_GETFL) = 0x2 (flags O_RDWR) fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK)= 0 connect(5, {sa_family=AF_INET, sin_port=htons(1935), sin_addr=inet_addr("52.223.195.194")}, 16) = -1 EINPROGRESS (Operation now in progress) poll([{fd=5, events=POLLOUT}], 1, 100) = 1 ([{fd=5, revents=POLLOUT}]) getsockopt(5, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 write(2, "\33[0;39m[rtmp @ 0x1f512c0] \33[0m", 30[rtmp @ 0x1f512c0] ) = 30 write(2, "\33[0;32mHandshaking...\n\33[0m", 26Handshaking... ) = 26 poll([{fd=5, events=POLLOUT}], 1, 100) = 1 ([{fd=5, revents=POLLOUT}]) sendto(5, "\3\0\0\0\0\t\0|\2\367xU\36\316\253\216\0366/\7\305\206\212p\262f\324\2 \345\10a"..., 1537, MSG_NOSIGNAL, NULL, 0) = 1537 poll([{fd=5, events=POLLIN}], 1, 100) = 0 (Timeout) On Tue, Dec 10, 2019 at 6:47 PM Verachten Bruno wrote: > Hi there, > > I unfortunately have to stream from behind a proxy. It works on one of my > machines thanks to redsocks. The RTMP handshake goes well, and I can stream > to twitch or youtube. > On another machine, with the same redsocks configuration, the handshake > never finishes,
[FFmpeg-user] RTMP handshaking behind a proxy
Hi there, I unfortunately have to stream from behind a proxy. It works on one of my machines thanks to redsocks. The RTMP handshake goes well, and I can stream to twitch or youtube. On another machine, with the same redsocks configuration, the handshake never finishes, be it with youtube or twitch. The ffmpeg command is just a copy of an already h.264 encoded stream from rtmp to rtmp. My question is: is there a random port opened for the negotiation? Where should I look for the blocking of the handshake? Here is the command I have and the output: ffmpeg -i "$SOURCE" -c:v copy -c:a copy -f flv "$YOUTUBE_URL/$KEY" -loglevel debug [...] Splitting the commandline. Reading option '-i' ... matched as input url with argument 'rtmp:// 192.168.1.217:1935/live/stream15'. Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'. Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'copy'. Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'. Reading option 'rtmp://live-cdg.twitch.tv/app/live_of_myself' ... matched as output url. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Finished splitting the commandline. Parsing a group of options: global . Applying option loglevel (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options: input url rtmp:// 192.168.1.217:1935/live/stream15. Successfully parsed a group of options. Opening an input file: rtmp://192.168.1.217:1935/live/stream15. [NULL @ 0xc401d0] Opening 'rtmp://192.168.1.217:1935/live/stream15' for reading [rtmp @ 0xc40990] No default whitelist set [tcp @ 0xc41010] No default whitelist set [tcp @ 0xc41010] Original list of addresses: [tcp @ 0xc41010] Address 192.168.1.217 port 1935 [tcp @ 0xc41010] Interleaved list of addresses: [tcp @ 0xc41010] Address 192.168.1.217 port 1935 [tcp @ 0xc41010] Starting connection attempt to 192.168.1.217 port 1935 [tcp @ 0xc41010] Successfully connected to 192.168.1.217 port 1935 [rtmp @ 0xc40990] Handshaking... [rtmp @ 0xc40990] Type answer 3 [rtmp @ 0xc40990] Server version 13.14.10.13 [rtmp @ 0xc40990] Proto = rtmp, path = /live/stream15, app = live, fname = stream15 [rtmp @ 0xc40990] Window acknowledgement size = 500 [rtmp @ 0xc40990] Max sent, unacked = 500 [rtmp @ 0xc40990] New incoming chunk size = 20480 [rtmp @ 0xc40990] Creating stream... [rtmp @ 0xc40990] Sending play command for 'stream15' [flv @ 0xc401d0] Format flv probed with size=2048 and score=100 [flv @ 0xc401d0] Before avformat_find_stream_info() pos: 13 bytes read:32868 seeks:0 nb_streams:0 [flv @ 0xc401d0] Unknown type |RtmpSampleAccess [NULL @ 0xc432a0] nal_unit_type: 7(SPS), nal_ref_idc: 3 [NULL @ 0xc432a0] nal_unit_type: 8(PPS), nal_ref_idc: 3 [NULL @ 0xc432a0] unknown SEI type 229 [h264 @ 0xc432a0] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0xc432a0] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0xc432a0] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0xc432a0] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0xc432a0] nal_unit_type: 6(SEI), nal_ref_idc: 0 [h264 @ 0xc432a0] nal_unit_type: 5(IDR), nal_ref_idc: 3 [h264 @ 0xc432a0] unknown SEI type 229 [h264 @ 0xc432a0] Format yuv420p chosen by get_format(). [h264 @ 0xc432a0] Reinit context to 1920x1088, pix_fmt: yuv420p [h264 @ 0xc432a0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3 Last message repeated 5 times [flv @ 0xc401d0] All info found [flv @ 0xc401d0] rfps: 29.75 0.015408 [flv @ 0xc401d0] rfps: 29.83 0.010802 [flv @ 0xc401d0] rfps: 29.916667 0.008256 [flv @ 0xc401d0] rfps: 30.00 0.007768 Last message repeated 1 times [flv @ 0xc401d0] rfps: 29.970030 0.007707 Last message repeated 1 times [flv @ 0xc401d0] Setting avg frame rate based on r frame rate [flv @ 0xc401d0] After avformat_find_stream_info() pos: 66491 bytes read:66491 seeks:0 frames:105 Input #0, flv, from 'rtmp://192.168.1.217:1935/live/stream15': Duration: N/A, start: 9159.905000, bitrate: N/A Stream #0:0, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(progressive, left), 1920x1080 (1920x1088), 0/1, 29.97 fps, 29.97 tbr, 1k tbn Stream #0:1, 64, 1/1000: Audio: aac (LC), 48000 Hz, stereo, fltp Successfully opened the file. Parsing a group of options: output url rtmp:// live-cdg.twitch.tv/app/live_of_myself. Applying option c:v (codec name) with argument copy. Applying option c:a (codec name) with argument copy. Applying option f (force format) with argument flv. Successfully parsed a group of options. Opening an output file: rtmp://live-cdg.twitch.tv/app/live_of_myself. [rtmp @ 0xc528c0] No default whitelist set [tcp @ 0xcacff0] No default whitelist set [tcp @ 0xcacff0] Original list of addresses: [tcp @ 0xcacff0] Address 52.223.195.16 port 1935 [tcp @ 0xcacff0] Address 52.223.195.119 port 1935 [tcp @ 0xcacff0] Address 52.223.195.169 port 1935 [tcp @ 0xcacff0] Address 52.223.195.205 port