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/

相关推荐
qetfw2 分钟前
Debian OpenLDAP 目录服务配置:DN、LDIF、ldapsearch 与认证验证
linux·运维·debian
wzq11_66619 分钟前
云计算运维学习day22——Ansible-Roles
运维·学习·云计算
HiDev_27 分钟前
【非标自动化】2、认识元器件(数字量输入输出模块)
运维·自动化
qq_3494479541 分钟前
在ollama下部署DeepSeek-r1模型(linux机器)
linux·运维·服务器
白猫不黑42 分钟前
AI Agent自动化渗透测试实战:从原理到红队实践
运维·人工智能·web安全·网络安全·信息安全·渗透测试·自动化
七夜zippoe1 小时前
DolphinDB 2.x 集群监控运维平台实战:从指标采集到告警自愈
运维·集群·监控·告警·dolphindb·指标采集
Lucky09281 小时前
codex 安装前置软件
linux·运维·macos
钝挫力PROGRAMER1 小时前
Windows Docker 环境搭建 GitLab CI/CD 流水线
windows·docker·gitlab·gitlab-runner
mengge.cloud1 小时前
0823Keepalived + LVS(DR) + MariaDB主主 小白完整实战教程
linux·运维·网络·oracle·负载均衡·mariadb·lvs
kk”9 小时前
Linux的组和权限管理
linux·运维·服务器