ffmpeg+easydarwin播放视频文件

 设置easydarwin

下载,解压,修改端口(可选),启动

修改 easydarwin.ini 文件的端口,和服务器的端口不冲突即可,建议把554改为551

登录 http://ip:10008 查看

设置ffmpeg

获取imge

线上拉取:docker pull jrottenberg/ffmpeg
文件导入:docker load -i ffmpeg_latest_with_nettools.tar
查看镜像:docker iamges | grep ffmpeg

运行容器 

dcoker run方式创建容器

docker run -it -d --name app_ffmpeg -p 8088:8080-v /data/ffmpeg_videos/:/mnt/app/ --entrypoint='bash' jrottenberg/ffmpeg

 docker-compose 方式创建容器(docker-compose.yml 文件)

复制代码
version: '3'
services:
  app_ffmpeg:
    image: jrottenberg/ffmpeg
image: jrottenberg/ffmpeg:latest_with_nettools # 如果是文件导入ffmpeg_latest_with_nettools.tar,就用这个 container_name:
"app_ffmpeg" network_mode: bridge restart: always ports: - 8088:8080 environment: - "LANG=en_US.UTF-8" volumes: - /data/ffmpeg_videos:/mnt/app/:ro - /etc/localtime:/etc/localtime:ro - /etc/hosts:/etc/hosts:ro - ./sources.list:/etc/apt/sources.list:ro entrypoint: ["/bin/bash", "-c" , "echo \"ffmpeg create succuss!!\"; touch /my_debug.log; tail -f /my_debug.log"]
复制代码

sources.list

复制代码
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
复制代码

启动 docker-compose up

添加视频文件

添加视频文件到/data/videos目录下,会自动映射到容器的/mnt/app/目录下

进入ffmpeg容器设置播放

复制代码
进入容器
docker exec -it app_ffmpeg /bin/bash
启动解析播放
nohup ffmpeg -re -stream_loop -1 -i /mnt/app/video.mp4 -vcodec libx264 -f rtsp -rtsp_transport tcp rtsp://*.*.*.*:551/video > /dev/null 2>&1 &
后面推送的rtsp地址,对应easydarwin的地址,注意端口对应上
上easydrawin页面,查看流的信息

可以播放多个视频文件,如
rtsp://*.*.*.*:551/video1
rtsp://*.*.*.*:551/video2
复制代码

 如果有些视频文件不支持循环播放,那么使用脚本解决

复制代码
进入容器
创建脚本
check.sh

脚本内容如下
while true
do
    sleep 1
    if ! ps -ef | grep ffmpeg | grep 视频关键字符串 > /dev/null
    then
        播放命令
    fi
done

执行脚本
nohup check.sh &
复制代码

 

posted @   szcj~  阅读(152)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示