Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtmp流无法播放,http可以 #37

Closed
lystormenvoy opened this issue Jun 1, 2018 · 7 comments
Closed

rtmp流无法播放,http可以 #37

lystormenvoy opened this issue Jun 1, 2018 · 7 comments

Comments

@lystormenvoy
Copy link

lystormenvoy commented Jun 1, 2018

流由另一个服务器的nginx使用push推送
配置文件:
#user nobody;
worker_processes 1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;
worker_rlimit_nofile 40960;

events {
    use epoll;
    worker_connections  10240;
}

rtmp {
    server {
            listen 9492;
            chunk_size 4096;
            application live {
                    live on;
                    max_connections 10240;
            }
            application hls {
                    live on;
                    gop_cache on;
                    hls on;
                    hls_path /usr/local/nginx/html/app;
                    hls_fragment 3s;
                    hls_playlist_length 30s;
                    hls_sync 100ms;
                    meta copy;
                    recorder chunked {
                            record all;
                            #record_max_size 6200K;
                            record_interval 10s;
                            record_suffix -%Y-%m-%d-%H_%M_%S.flv;
                            record_path /AVA/data/Upload/Rec/Chunked;
                    }
                    recorder all {
                            record all;
                            record_suffix -%Y-%m-%d-%H_%M_%S.flv;
                            record_max_size 6200000K;
                            record_path /AVA/data/Upload/Rec;
                    }
            }
            application Upload {
                    play /ava_app/school/src/tomcat/webapps/admin/upload;
            }
    }
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       9491;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location /live {
            flv_live on;
            chunked_transfer_encoding off;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
        }

        location /hls {
                    types {
                            #application/vnd.apple.mpegurl m3u8;
                            application/x-mpegurl m3u8;
                            video/mp2t ts;
                    }
                    alias /usr/local/nginx/html/app;
            }
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root html;
        }
    }
}
@lystormenvoy
Copy link
Author

ffmpeg 提示
ffmpeg -loglevel debug -i rtmp://192.168.2.71:9492/hls/lvs
ffmpeg version 2.6.3 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --prefix=/usr/local/ --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-zlib --enable-bzlib --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libx264 --enable-libxvid --enable-pic --enable-pthreads --enable-libdc1394 --enable-libass --enable-pic --enable-openssl --enable-libtwolame --enable-libspeex --enable-libfreetype
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input file with argument 'rtmp://192.168.2.71:9492/hls/lvs'.
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 file rtmp://192.168.2.71:9492/hls/lvs.
Successfully parsed a group of options.
Opening an input file: rtmp://192.168.2.71:9492/hls/lvs.
[rtmp @ 0x1a326e0] Handshaking...
[rtmp @ 0x1a326e0] Type answer 3
[rtmp @ 0x1a326e0] Server version 13.14.10.13
[rtmp @ 0x1a326e0] Proto = rtmp, path = /hls/lvs, app = hls, fname = lvs
[rtmp @ 0x1a326e0] Server bandwidth = 5000000
[rtmp @ 0x1a326e0] Client bandwidth = 5000000
[rtmp @ 0x1a326e0] New incoming chunk size = 4096
[rtmp @ 0x1a326e0] Creating stream...
[rtmp @ 0x1a326e0] Sending play command for 'lvs'
[rtmp @ 0x1a326e0] Deleting stream...
rtmp://192.168.2.71:9492/hls/lvs: Invalid data found when processing input

@winshining
Copy link
Owner

编译的时候加--with-debug,然后在conf文件里的error_log最后加debug,重启,然后看打印日志哪儿有问题

@lystormenvoy
Copy link
Author

debug日志刷得飞快啊,只能截最后出现我客户端IP的那部分了
2018/06/01 16:09:08 [debug] 17636#0: epoll: fd:14 ev:2019 d:00007FA976F11498
2018/06/01 16:09:08 [debug] 17636#0: epoll_wait() error on fd:14 ev:2019
2018/06/01 16:09:08 [debug] 17636#0: *2 recv: eof:1, avail:1
2018/06/01 16:09:08 [debug] 17636#0: *2 recv: fd:14 -1 of 138
2018/06/01 16:09:08 [info] 17636#0: *2 recv() failed (104: Connection reset by peer), client: 192.168.2.39, server: 0.0.0.0:9492
2018/06/01 16:09:08 [debug] 17636#0: *2 finalize session
2018/06/01 16:09:08 [debug] 17636#0: *2 post event 0000000001310B38
2018/06/01 16:09:08 [debug] 17636#0: timer delta: 0
2018/06/01 16:09:08 [debug] 17636#0: posted event 0000000001310B38
2018/06/01 16:09:08 [debug] 17636#0: *2 delete posted event 0000000001310B38
2018/06/01 16:09:08 [debug] 17636#0: *2 close session
2018/06/01 16:09:08 [info] 17636#0: *2 disconnect, client: 192.168.2.39, server: 0.0.0.0:9492
2018/06/01 16:09:08 [info] 17636#0: *2 deleteStream, client: 192.168.2.39, server: 0.0.0.0:9492
2018/06/01 16:09:08 [debug] 17636#0: *2 live: leave 'lvs'
2018/06/01 16:09:08 [debug] 17636#0: *2 create: stream_end msid=1
2018/06/01 16:09:08 [debug] 17636#0: *2 RTMP prep user (4) fmt=0 csid=2 timestamp=0 mlen=6 msid=0 nbufs=1
2018/06/01 16:09:08 [debug] 17636#0: *2 live: set active=0
2018/06/01 16:09:08 [debug] 17636#0: *2 RTMP send nmsg=1, priority=0 #14
2018/06/01 16:09:08 [debug] 17636#0: *2 record: close_stream
2018/06/01 16:09:08 [debug] 17636#0: *2 malloc: 000000000139AD70:660
2018/06/01 16:09:08 [debug] 17636#0: shmtx lock
2018/06/01 16:09:08 [debug] 17636#0: shmtx unlock
2018/06/01 16:09:08 [debug] 17636#0: *2 limit: dec conection counter: 1
2018/06/01 16:09:08 [debug] 17636#0: *2 event timer del: 14: 161392497
2018/06/01 16:09:08 [debug] 17636#0: *2 free: 0000000001396BE0, unused: 3526
2018/06/01 16:09:08 [debug] 17636#0: *2 free: 0000000001395BD0, unused: 2736
2018/06/01 16:09:08 [debug] 17636#0: *2 free: 000000000138DBC0
2018/06/01 16:09:08 [debug] 17636#0: *2 free: 000000000130E470, unused: 4000
2018/06/01 16:09:08 [debug] 17636#0: *2 close connection
2018/06/01 16:09:08 [debug] 17636#0: *2 reusable connection: 0

@winshining
Copy link
Owner

看不出来错误,你最好再往更前面的日志看,我怀疑是配置有问题,我试过ffmpeg接收流是可以的:
[rtmp @ 0x7ff335e00360] Sending bytes read report0:00:40.06 bitrate=17211.5kbits/s speed=1.03x
[rtmp @ 0x7ff335e00360] Sending bytes read report0:00:41.06 bitrate=17227.3kbits/s speed=1.02x
[rtmp @ 0x7ff335e00360] Sending bytes read report0:00:42.06 bitrate=17230.2kbits/s speed=1.04x
No more output streams to write to, finishing.
[flv @ 0x7ff336000000] Failed to update header with correct duration.
[flv @ 0x7ff336000000] Failed to update header with correct filesize.
frame= 1277 fps= 31 q=-1.0 Lsize= 89618kB time=00:00:42.51 bitrate=17269.3kbits/s speed=1.05x
video:88566kB audio:994kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.065336%
Input file #0 (rtmp://localhost/myapp/mystream):
Input stream #0:0 (video): 1277 packets read (90691461 bytes);
Input stream #0:1 (audio): 1988 packets read (1017845 bytes);
Total: 3265 packets (91709306 bytes) demuxed
Output file #0 (rtmp://localhost/test/output):
Output stream #0:0 (video): 1277 packets muxed (90691461 bytes);
Output stream #0:1 (audio): 1988 packets muxed (1017845 bytes);
Total: 3265 packets (91709306 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7ff335e010e0] Statistics: 0 seeks, 5388 writeouts
[rtmp @ 0x7ff335c0d320] UnPublishing stream...
[rtmp @ 0x7ff335c0d320] Deleting stream...
[AVIOContext @ 0x7ff335e00fe0] Statistics: 91769226 bytes read, 0 seeks
[rtmp @ 0x7ff335e00360] Deleting stream...

@lystormenvoy
Copy link
Author

配置文件就上面贴的那个

@lystormenvoy
Copy link
Author

测试了一下,ffmpeg直接推服务器是没问题的。
不过我是ffmpeg推另一个服务器,另一个服务器的nginx自动push过来的,这种情况就播放不了了。stat页面能看到有流进来的。
image

@winshining
Copy link
Owner

push

最上面的那个框表示本地服务器的配置,中间那个框表示往本地服务器推流,然后它再push到别的服务器,下面那个框表示从上面那个服务器请求RTMP流,没有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants