MJPEG广播器
项目描述
使用MJPEG和nginx_push_stream创建实时缩略图。
用法
编译支持nginx_push_stream的Nginx。示例配置还使用了lua-nginx-module和lua-resty-redis来存储和从Redis提供旧快照,但此模块是可选的。Nginx配置应类似于以下内容
$ LUAJIT_LIB=/usr/local/lib/ LUAJIT_INC=/usr/local/include/luajit-2.0 ./configure --add-module=../nginx-push-stream-module --add-module=../lua-nginx-module --with-pcre --with-ipv6 --with-ld-opt=-L/usr/local/lib
现在使用示例配置运行Nginx
$ nginx -c $PWD/nginx.conf
创建一个目录来存储缩略图
$ mkdir -p frames/parts
使用ffmpeg为频道创建缩略图(本例中的parts)
$ ffmpeg -re -i rtmp://example.com/live/stream -vf "scale=159:-1" -r 3 frames/parts/thumb%9d.jpg
运行广播器
$ python broadcaster.py
如果您愿意,可以使用pip安装脚本并运行它
$ pip install live_thumb $ broadcaster
使用示例html观看电影
$ open test.html
或者直接访问http://localhost:9080/sub/parts。
如果要同时将快照存储在redis中,您应该在运行广播器时添加一个额外的环境变量
$ REDIS_HOST="localhost" REDIS_PORT=7000 python broadcaster.py
快照将来自http://localhost:9080/snapshot/parts。您也可以指定一个时间戳:http://localhost:9080/snapshot/parts?timestamp=1396381230