在nginx_rtmp_module上未创建HLS文件(.m3u8,.ts)

问题描述 投票:0回答:1

我想使用ffmpeg和nginx_rtmp_module将RTSP转换为RTMP到HLS。

但是没有创建HLS文件(.m3u8,.ts)。

我正在测试Docker(amazonlinux图像)。

我可以通过VLC播放器访问和播放rtmp://localhost:1935/live/camera1,但无法访问http://localhost:8088/live/camera1.m3u8

docker run命令:

docker run -it -p 8088:8088 -p 1935:1935 -v $(pwd):/tmp/share amazonlinux bash

nginx.conf:

user root;
worker_processes  1;
error_log  /var/log/nginx/error.log debug;

events {
  worker_connections  1024;
}

rtmp {
  server {
    listen 1935;
    access_log  /var/log/nginx/rtmp_access.log;
    application live {
      live on;
      hls on;
      hls_path /usr/local/nginx/html/hls;
      hls_fragment 5s;
      hls_type live;
      hls_nested on;
    }
  }
}

http {
  server {
    listen      8088;

    location / {
      root /usr/local/nginx/html/;
    }

    location /hls {
      types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
        text/html html;
      }

      alias /usr/local/nginx/html/hls;
    }
  }
}

ffmpeg命令:(使用示例视频rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov

nohup /root/ffmpeg_sources/ffmpeg/ffmpeg -i "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov" -f flv -s 320x240 -an "rtmp://localhost:1935/live/camera1" </dev/null &

ffmpeg版本:

bash-4.2# /root/ffmpeg_sources/ffmpeg/ffmpeg -version
ffmpeg version N-90214-gdd3f1e3 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libx264 --enable-nonfree
libavutil      56.  8.100 / 56.  8.100
libavcodec     58. 13.102 / 58. 13.102
libavformat    58. 10.100 / 58. 10.100
libavdevice    58.  2.100 / 58.  2.100
libavfilter     7. 12.100 /  7. 12.100
libswscale      5.  0.102 /  5.  0.102
libswresample   3.  0.101 /  3.  0.101
libpostproc    55.  0.100 / 55.  0.100

nginx版本:nginx version: nginx/1.13.9

nginx_rtmp_module版本:nginx-rtmp-module-1.2.1

和目录权限:

bash-4.2# pwd
/usr/local/nginx/html
bash-4.2# ls -l
total 48
-rw-r--r-- 1 root root   537 Mar  5 07:24 50x.html
drwxrwxrwx 2 root root  4096 Mar  6 04:46 hls
-rw-r--r-- 1 root root   612 Mar  5 07:24 index.html
-rw------- 1 root root 36262 Mar  6 04:46 nohup.out

救命...

nginx ffmpeg
1个回答
0
投票

我解决了自己。

我发现用README写的Incoming stream must be in H264/AAC.

所以,我将-vcodec libx264添加到ffmpeg命令中:

nohup /root/ffmpeg_sources/ffmpeg/ffmpeg -stream_loop -1 -i "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov" -vcodec libx264 -f flv -s 320x240 -an "rtmp://localhost:1935/live/camera1" </dev/null &
© www.soinside.com 2019 - 2024. All rights reserved.