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 小时前
Linux — 进程控制
android·linux·运维
JoneBB1 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
Tolalal2 小时前
Vmware Ubuntu虚拟机扩容
linux·运维·ubuntu
修己xj2 小时前
别再让Docker占满你的硬盘!一篇搞定docker system所有命令
docker
咚为3 小时前
比AccessLog更全面的原生Nginx 日志记录
运维·nginx·junit
我星期八休息3 小时前
Linux系统编程—基础IO
linux·运维·服务器·c语言·c++·人工智能·算法
a752066283 小时前
零基础实操:小龙虾 AI OpenClaw 接入 Kimi 详细步骤
运维·服务器
Goldbioinformatics3 小时前
Windows版Claude Cowork启动Linux问题
linux·运维·windows
念恒123064 小时前
Ext系列文件系统(下)
linux·运维·服务器