流媒体服务器
# SRS
# 安装
version: "2"
services:
srs:
restart: "always"
container_name: srs
image: registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5
ports:
- "1935:1935"
- "1985:1985"
- "8080:8080"
- "8000:8000"
environment:
CANDIDATE: 能访问到的地址
# 推流
# RTMP
ffmpeg -re -i zz.mp4 -vcodec libx264 -acodec aac -f flv "rtmp://192.168.1.100/live/livestream"
# 播放地址:
RTMP: rtmp://192.168.1.100/live/livestream
HLS: http://192.168.1.100:8080/live/livestream.m3u8
FLV: http://localhost:8080/live/livestream.flv
# ZLM
# 安装
version: "2"
services:
ZLMediaKit:
restart: "no"
container_name: ZLMediaKit
image: zlmediakit/zlmediakit:master
# image: zlmediakit/zlmediakit:Release.1.0.2
ports:
- "1935:1935"
- "180:180"
- "1443:1443"
- "1554:1554"
- "1935:1935/udp"
- "1554:1554/udp"
- "10000:10000"
- "10000:10000/udp"
- "8000:8000/udp"
- "9000:9000/udp"
- "35000-35010:35000-35010/tcp"
- "35000-35010:35000-35010/udp"
volumes:
- ./conf:/opt/media/conf
- ./log:/opt/media/bin/log
# 编译
clone 项目
sh build_docker_images.sh -t build -p x86_64 -m Release -v 1.0.2
# 推流
# 使用rtsp方式推流
# h264推流
ffmpeg -re -i "/path/to/test.mp4" -vcodec h264 -acodec aac -f rtsp -rtsp_transport tcp rtsp://127.0.0.1/live/test
# h265推流
ffmpeg -re -i "/path/to/test.mp4" -vcodec h265 -acodec aac -f rtsp -rtsp_transport tcp rtsp://127.0.0.1/live/test
# 使用rtmp方式推流
# rtmp推流
ffmpeg -re -i "/path/to/test.mp4" -vcodec h264 -acodec aac -f flv rtmp://127.0.0.1/live/test
# 使用rtp方式推流
# h264推流
ffmpeg -re -i "/path/to/test.mp4" -vcodec h264 -acodec aac -f rtp_mpegts rtp://127.0.0.1:10000
# h265推流
ffmpeg -re -i "/path/to/test.mp4" -vcodec h265 -acodec aac -f rtp_mpegts rtp://127.0.0.1:10000
# 桌面录制
ffmpeg -re -f gdigrab -i desktop -vcodec h264 -acodec aac -f rtp_mpegts rtp://127.0.0.1:10000
ffmpeg -f gdigrab -framerate 30 -i desktop -fflags nobuffer -probesize 32 -analyzeduration 0 -c:v libx264 -preset ultrafast -tune zerolatency -g 30 -b:v 2M -s 1280x720 -f rtp_mpegts rtp://192.168.1.226:10000
# URL 规则
# RTSP
rtsp://127.0.0.1:554/rtp/test
# RTMP
rtmp://192.168.1.226:1935/rtp/test
http://192.168.1.226/live/test.live.flv
ws://192.168.1.226/live/test.live.flv
# HLS(mpegts)
http://192.168.1.226/live/test/hls.m3u8
# HLS(fmp4)
http://192.168.1.226/live/test/hls.fmp4.m3u8
# .live.ts
http://192.168.1.226/live/test.live.ts
ws://192.168.1.226/live/test.live.ts
# .live.mp4
http://192.168.1.226/live/test.live.mp4
ws://192.168.1.226/live/test.live.mp4
上次更新: 2024/11/05, 08:29:31