winshining/nginx-http-flv-module

ffmpeg [rtmp]: Cannot open connection tcp://127.0.0.1:1935?tcp_nodelay=0

veasion opened this issue · 1 comments

通过 ffmpeg 往 nginx rtmp 模块推流时发现连接不上服务器(只推送音频)。

OS and Nginx version

centos 7, nginx-1.21.1, ffmpeg 6.0

nginx 配置

worker_processes 2;

events {
  worker_connections 1024;
}

rtmp {
  server {
    listen 1935;
    chunk_size 4096;
    allow play all;
    allow publish all;

    application live {
      live on;
      hls off;
      record off;
    }

  }
}
command = ['ffmpeg',
		   '-y',
		   '-re',
		   '-vn',
		   '-f', 's16le',
		   '-acodec', 'pcm_s16le',
		   '-ac', '1',
		   '-ar', '16000',
		   '-i', '-',
		   '-ac', '1',
		   '-ar', '16000',
		   '-c:a', 'aac',
		   '-b:a', '64k',
		   '-f', 'flv',
		   'rtmp://127.0.0.1/live/test'
		   ]
pipe = subprocess.Popen(command, stdin=subprocess.PIPE, shell=False)

pipe.stdin.write(frame_bytes)

ffmpeg debug 信息:
Opening an output file: rtmp://127.0.0.1/live/test.
[rtmp @ 0x15e3400] No default whitelist set
[tcp @ 0x15e3b00] No default whitelist set
[tcp @ 0x15e3b00] Original list of addresses:
[tcp @ 0x15e3b00] Address 127.0.0.1 port 1935
[tcp @ 0x15e3b00] Interleaved list of addresses:
[tcp @ 0x15e3b00] Address 127.0.0.1 port 1935
[tcp @ 0x15e3b00] Starting connection attempt to 127.0.0.1 port 1935
[rtmp @ 0x15e3400] Cannot open connection tcp://127.0.0.1:1935?tcp_nodelay=0
rtmp://127.0.0.1/live/test: Immediate exit requested