1.说明
本文使用Nginx搭建视频点播服务。也是最简单的一种配置方式。使用在hub.docker.com中的rtmp-hls最新的镜像搭建。
所要达到的目标也非常简单: 将mp4文件通过rtmp协议进行在线播放。
2.参考地址
https://hub.docker.com/r/alqutami/rtmp-hls
https://github.com/arut/nginx-rtmp-module
3.镜像
使用到的镜像为:当前时间(2020-05-08)
alqutami/rtmp-hls:latest
4.镜像获取
拉取docker镜像的命令如下:
docker pull alqutami/rtmp-hls:latest
5.获取配置
查看镜像配置信息
docker run -it -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls cat /etc/nginx/nginx.conf
输出如下:
worker_processes auto;
#error_log logs/error.log;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
# ping 30s;
# notify_method get;
# This application is to accept incoming stream
application live {
live on; # Allows live input
# for each received stream, transcode for adaptive streaming
# This single ffmpeg command takes the input and transforms
# the source into 4 different streams with different bitrates
# and qualities. # these settings respect the aspect ratio.
exec_push /usr/local/bin/ffmpeg -i rtmp://localhost:1935/$app/$name -async 1 -vsync -1
-c:v libx264 -c:a aac -b:v 256k -b:a 64k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_low
-c:v libx264 -c:a aac -b:v 768k -b:a 128k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_mid
-c:v libx264 -c:a aac -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_high
-c:v libx264 -c:a aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_hd720
-c copy -f flv rtmp://localhost:1935/show/$name_src;
}
# This is the HLS application
application show {
live on; # Allows live input from above application
deny play all; # disable consuming the stream from nginx as rt

本文介绍如何使用Nginx和Docker镜像搭建视频点播服务,包括配置rtmp-hls镜像,实现mp4文件通过RTMP协议在线播放,以及使用VLC和vue-video-player进行播放的方法。
最低0.47元/天 解锁文章
876

被折叠的 条评论
为什么被折叠?



