docker里rtsp推流+同一个docker接受流进行部署

1.参考:

https://blog.csdn.net/m0_57609406/article/details/140323327

2.dockerfile命令

bash 复制代码
# 使用官方 Python 基础镜像
FROM python:3.8.18-slim

# 设置工作目录
WORKDIR /usr/src/app

# 安装必要的软件包(FFmpeg、OpenCV、lsof、RTSP工具)
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free" > /etc/apt/sources.list && \
    echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \
    apt-get update && apt-get install -y \
    wget \
    vim \
    ffmpeg \
    lsof \
    libgl1-mesa-glx \
    libglib2.0-0 \
    python3-opencv \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# 下载并安装 RTSP Simple Server
RUN wget https://github.com/aler9/rtsp-simple-server/releases/download/v0.17.0/rtsp-simple-server_v0.17.0_linux_amd64.tar.gz \
    && tar -zxvf rtsp-simple-server_v0.17.0_linux_amd64.tar.gz \
    && rm rtsp-simple-server_v0.17.0_linux_amd64.tar.gz

# 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 复制项目代码到容器
COPY . .

# 暴露 Flask 和 RTSP 端口
EXPOSE 11115
EXPOSE 8554
EXPOSE 5004

# 启动 RTSP 服务和项目应用
CMD ["bash", "-c", "./rtsp-simple-server & ffmpeg -re -stream_loop -1 -i fire.mp4 -c:v copy -f rtsp rtsp://0.0.0.0:8554/stream & python app.py"]

3.docker命令

bash 复制代码
docker build -t rtsp-server-app .
docker run -d --name rtsp-container -p 11115:11115 -p 8554:8554 rtsp-server-app

4.运行

打开http://localhost:11115/

相关推荐
木叶子---1 分钟前
Docker
运维·docker·容器
CryptoPP24 分钟前
对接API获取马来西亚历史数据
linux·运维·服务器·金融·区块链
Cyber4K38 分钟前
【Kubernetes专项】K8s集群1.31版本安装手册
linux·docker·云原生·容器·kubernetes
凯子坚持 c39 分钟前
基于Docker的SD-WAN组网方案:利用节点小宝实现服务器远程开发
服务器·docker·容器
盈创力和200743 分钟前
以太网温湿度传感器如何提升机房环境监控的自动化与可靠性?
运维·自动化·以太网温湿度传感器·多协议支持·网络型温湿度传感器·物联网温湿度变送器·双重供电温湿度传感器
曹天骄1 小时前
子域名交给 Cloudflare(DNS 委派)现在不行了
运维
橘子真甜~1 小时前
Reids命令原理与应用5 - Redis 主从同步与高可用集群
运维·网络·数据库·redis·缓存·redis集群·redis高可用
陈让然1 小时前
WSL2 ubuntu18.04扩容
linux·运维·ubuntu
HIT_Weston2 小时前
94、【Ubuntu】【Hugo】搭建私人博客:面包屑(二)
linux·运维·ubuntu