gnolizuh / BLSS

NGINX-based Live Media Streaming Server
Other
197 stars 73 forks source link

Cannot play stream #113

Closed warlock135 closed 6 years ago

warlock135 commented 6 years ago

Hi, Im trying to use your module to implement a streaming server. Here is my config (basically the same as in your readme)

worker_processes 1;   # multi-worker process mode
relay_stream hash;    # stream relay mode

events {
worker_connections 1024;
}

rtmp {
    server {
        listen 1935 reuseport;

        service cctv {
            hostname pub rtmp localhost;      # match rtmp push domain
            hostname sub rtmp localhost;     # match rtmp pull domain
            hostname sub http_flv localhost;  # match http-flv pull domain

            application live {
                live on;
                gop_cache on;
                gop_cache_count 5;  # cache 5 GOPs

                hls on;
                hls_fragment 10s;
                hls_playlist_length 30s;
            }
        }
    }
}

Streaming into the server with ffmpeg works fine. Here is my command: ./ffmpeg -f pulse -ac 2 -i default -f x11grab -framerate 25 -video_size 1440x1080 -i :0.0+0,0 -async 1 -vsync 1 -c:v libx264 -crf 23 -preset superfast -vf "format=yuv420p" -g 60 -tune zerolatency -movflags +faststart -fflags +genpts -avoid_negative_ts make_zero -c:a aac -b:a 128k -ar 44100 -f flv rtmp://localhost/live/test

But when i try to play the stream with ffplay: ./ffplay rtmp://localhost/live/test

RTMP_ReadPacket, failed to read RTMP packet headersq=    0B f=0/0   
rtmp://localhost/live/test: Unknown error occurred

Here is the log:

2018/09/28 19:29:25 [info] 5465#0: *1 client connected '127.0.0.1'
2018/09/28 19:29:25 [info] 5465#0: *1 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=0 vcodecs=0 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 releaseStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 fcpublish, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 publish: name='test' args='' type=live silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 gop cache publish: name='test' type='live', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 client connected '127.0.0.1'
2018/09/28 19:29:36 [info] 5465#0: *2 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 play: name='test' args='' start=0 duration=0 reset=0 silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 play: service not found: 'localhost', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 disconnect, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 deleteStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 client connected '127.0.0.1'
2018/09/28 19:30:17 [info] 5465#0: *3 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 play: name='test' args='' start=0 duration=0 reset=0 silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 play: service not found: 'localhost', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 disconnect, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 deleteStream, client: 127.0.0.1, server: 0.0.0.0:1935

Is that the correct url to play the stream if I use that config? I also try with another server but the result is the same.

Thank in advance!

gnolizuh commented 6 years ago

it's a bug, hostname can not be the same one.you can config like this:

hostname pub rtmp localhost; 
hostname sub rtmp 127.0.0.1;

and ./ffplay rtmp://127.0.0.1/live/test

warlock135 commented 6 years ago

Thank for your reply. I already tried to use another server rather than localhost, somethings like this:

hostname pub rtmp 10.x.x.x;
hostname sub rtmp localhost;

but still got the same error. Aw, I will try your suggestion and give you further details when I'm back to my office on Monday.

warlock135 commented 6 years ago

Hi, With a fresh nginx + your module, it works now with localhost. Maybe there are some conflicts between the modules and some arut-rtmp patches which i applied before. But when I try with another server on the network, I still cant play the stream. ffplay just hangs and timeout after a few second. ffplay command: ./ffplay rtmp://localhost/live/test And the error: RTMP_ReadPacket, failed to read RTMP packet headersq= 0B f=0/0 Here is the host config:

hostname pub rtmp 10.58.201.130;      # match rtmp push domain
hostname sub rtmp localhost;     # match rtmp pull domain

I also can play the stream directly from the outside server with ffplay: ./ffplay rtmp://10.58.201.130/live/test Another thing, wireshark shows no packet to the server (10.58.201.130) when I try to play with the "localhost" command above. So I think there is some problem in pulling the stream from the origin server.

warlock135 commented 6 years ago

Nevermind, I had some misunderstandings about the hostname config. Thank for your help!