jrottenberg / ffmpeg

Docker build for FFmpeg on Ubuntu / Alpine / Centos / Scratch / nvidia / vaapi
https://hub.docker.com/r/jrottenberg/ffmpeg/
Apache License 2.0
1.42k stars 455 forks source link

Connection refused #290

Open MikEarpp opened 3 years ago

MikEarpp commented 3 years ago

Hello

I cannot use the container.

Here is the command used: docker run -p 4444:1935 jrottenberg/ffmpeg:4.1 -rtsp_transport tcp -i "rtsp://10.0.0.199:554/user=admin&password=pass&channel=0&stream=0.sdp" -vn -c:a aac -strict -2 -f flv "rtmp://127.0.0.1/live"

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609 configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-small --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://10.0.0.199:554/user=admin&password=pass&channel=0&stream=0.sdp': Metadata: title : RTSP Session Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 12 fps, 12 tbr, 90k tbn, 24 tbc Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s [tcp @ 0x1c9aa40] Connection to tcp://127.0.0.1:1935 failed: Connection refused [rtmp @ 0x1df9500] Cannot open connection tcp://127.0.0.1:1935 rtmp://127.0.0.1/live: Connection refused

The same command on the host works fine: ffmpeg -rtsp_transport tcp -i "rtsp://10.0.0.199:554/user=admin&password=pass&channel=0&stream=0.sdp" -vn -c:a aac -strict -2 -f flv "rtmp://127.0.0.1/live"

root@frigate:/opt/frigate# ffmpeg -rtsp_transport tcp -i "rtsp://10.0.0.199:554/user=admin&password=root&channel=0&stream=0.sdp" -vn -c:a aac -strict -2 -f flv "rtmp://127.0.0.1/live" ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04) configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libfreetype --enable-libvidstab --enable-libmfx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://10.0.0.199:554/user=admin&password=pass&channel=0&stream=0.sdp': Metadata: title : RTSP Session Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 12 fps, 12 tbr, 90k tbn, 24 tbc Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s Stream mapping: Stream #0:1 -> #0:0 (pcm_alaw (native) -> aac (native)) Press [q] to stop, [?] for help [aac @ 0x56059d07e680] Too many bits 8832.000000 > 6144 per frame requested, clamping to max Output #0, flv, to 'rtmp://127.0.0.1/live': Metadata: title : RTSP Session encoder : Lavf58.45.100 Stream #0:0: Audio: aac ([10][0][0][0] / 0x000A), 8000 Hz, mono, fltp, 48 kb/s Metadata: encoder : Lavc58.91.100 aac size= 127kB time=00:00:23.29 bitrate= 44.6kbits/s speed= 1.1x

Where is the problem?

jidckii commented 3 years ago

127.0.0.1 in container != 127.0.0.1 on host. Remove -p 4444:1935 and set --net host

MikEarpp commented 3 years ago

I had thought about it but I don't want to use a container in host mode. I still have processes that are not migrated to docker and port 1935 is used on my host.

I can expose another port than 4444 but not 1935.

thanks anyway

jidckii commented 3 years ago

then use not localhost but any external interface on host

docker run -p 4444:1935 jrottenberg/ffmpeg:4.1 -rtsp_transport tcp -i "rtsp://10.0.0.199:554/user=admin&password=pass&channel=0&stream=0.sdp" -vn -c:a aac -strict -2 -f flv "rtmp://192.168.88.11/live"
MikEarpp commented 3 years ago

On the host I have several interfaces: WAN 192.168.1.2 (connected to my 4G router) LAN 10.0.0.1

When I try with rtmp: //192.168.88.11/live I get: Connection to tcp: //192.168.88.11: 1935 failed: Connection timed out

With an existing interface: Connection to tcp: //192.168.1.11: 1935 failed: No route to host or Error writing trailer of rtmp://192.168.1.2/live: Broken pipe

With 10.0.0.1 Error writing trailer of rtmp: //10.0.0.1/live: Broken pipe size = 0kB time = 00: 00: 00.00 bitrate = N / A speed = 0x video: 0kB audio: 1kB subtitle: 0kB other streams: 0kB global headers: 0kB muxing overhead: unknown [aac @ 0xea1400] Qavg: 135.950 Conversion failed!

What bothers me is that when I try the same command in another container (blakeblackshear / frigate inspired by jrottenberg / ffmpeg) it works fine. I looked at the Dockerfiles but can't see why it doesn't work the same.

jidckii commented 3 years ago

192.168.88.11 this is me just for example. this my lan ip Where are you trying to send the rtmp stream to? On the other hand, who accepts?

MikEarpp commented 3 years ago

Very nice to worry about my problem :)

In fact I would like to send the stream via reverse ssh to a VPS server rented from OVH. Because because of my 4G connection (CGNAT) it is impossible to connect to my home from outside. This would allow my father who is in Paris to listen to the sounds of his country house.

I have another container that uses this technique successfully. autossh -p $_PORT_SSH -fNC -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i ~/.ssh/id_rsa -R \*:8070:127.0.0.1:5000 user@mydomain.at.ovh

With this command I forward the port 5000 of my container to the OVH server. Then we can connect from anywhere on http://mydomain.at.ovh:8070

So my idea is to forward port 1935 from the ffmpeg container to the same server. Then my dad will use VLC to connect to rtsp://mydomain.at.ovh:4444

MikEarpp commented 3 years ago

@jidckii : ты большой засранец