利用ffmpeg 把.mp4转换为.flv
1. 下载安装 ffmpeg
http://ffmpeg.org/download.html#build-windows
windows下载编译之后的exe文件,放到path环境变量中.
Linux 下
tar xvf xxx.tar.bz2
./configure --prefix=/usr/local/ffmpeg
make -j2
sudo make install
sudo ln -s /usr/local/ffmpeg /usr/local/bin/ffmpeg
2. 执行命令行
ffmpeg -i ~/media/dragon.mp4 -c:v copy -c:a copy dragon.flv
参考文档: https://www.cnblogs.com/lemos/p/8188344.html
3. 运行流媒体服务
git clone https://github.com/gwuhaolin/livego
go build
./livego
运行结果如下:
2020/02/20 16:46:10 main.go:118: start livego, version master
2020/02/20 16:46:10 liveconfig.go:35: starting load configure file(.livego.json)......
2020/02/20 16:46:10 liveconfig.go:42: loadconfig:
{
"server": [
{
"appname": "live",
"liveon": "on",
"hlson": "on"
}
]
}
2020/02/20 16:46:10 liveconfig.go:49: get config json data:{[{live on on []}]}
2020/02/20 16:46:10 main.go:62: hls server enable....
2020/02/20 16:46:10 main.go:70: RTMP Listen On :1935
2020/02/20 16:46:10 main.go:43: HLS listen On :7002
2020/02/20 16:46:10 main.go:87: HTTP-FLV listen On :7001
2020/02/20 16:46:10 main.go:105: HTTP-Operation listen On :8090
4.上行推流:通过 RTMP
协议把视频流推送到 rtmp://47.93.27.106:1935/live/dragon
,
例如使用
ffmpeg -re -i ~/media/dragon.flv -c copy -f flv rtmp://47.93.27.106:1935/live/dragon
推送
5. 下行播放:
支持以下三种播放协议,播放地址如下:
rtmp://47.93.27.106:1935/live/dragon
http://47.93.27.106:7001/live/dragon.flv
http://47.93.27.106:7002/live/dragon.m3u8
6. 用vlc player播放
Media => Open Network Stream
输入URL => Player
上一篇: 为什么要查找oom