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 小时前
Jenkins + Docker 完整部署指南
ubuntu·docker·jenkins
雨大王5122 小时前
汽车生产智能计划助手如何提升排产效率并降低库存积压?
大数据·运维
以太浮标3 小时前
华为eNSP综合实验之- 3a认证配置案例及解析(AAA认证)
运维·tcp/ip·网络安全·华为·信息与通信
No8g攻城狮3 小时前
【Linux】Linux nano 编辑器全攻略:从入门到精通
linux·运维·编辑器·nano
2301_805962934 小时前
arduino IDE如何设置代理
运维·服务器
shughui5 小时前
Docker Desktop下载、安装、配置、使用
运维·docker·容器·自动化
huaweichenai5 小时前
Linux安装http-server并部署html静态站点
linux·运维·服务器
Gss7775 小时前
Linux 正则表达式详解(基础 + 扩展 + 实操)
linux·运维·正则表达式
北冥湖畔的燕雀6 小时前
Linux权限与Vim,gcc以及make/makefile操作全解析
linux·运维·服务器
代码游侠6 小时前
Linux驱动复习——驱动
linux·运维·arm开发·笔记·学习