winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.71k stars 567 forks source link

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

Closed veasion closed 9 months ago

veasion commented 9 months ago

通过 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