下载m3u8的ffmpeg命令:
$ mkdir mydir
$ ffmpeg -i http://xxx.com/hls/record.m3u8 -c copy mydir/out.mp4
如果完整的ts流,中间没有中断过。那么在mydir目录直接就生成out.mp4了。
但是我这里不幸出现错误:
[mp4 @ 0x1104490] Application provided duration: 8431004738 / timestamp: 8537426612 is out of range for mov/mp4 format
[mp4 @ 0x1104490] pts has no value
这样只好自己手工下载m3u8文件中的ts文件然后再合并。
首先可以通过下面命令生成一个ts文件dowload列表:
$ curl -s http://xxx.com/hls/record.m3u8 | grep '.ts' | xargs -n 1 -I{} echo 'http://xxx.com/hls/{}' > download-list.txt
$ cat download-list.txt
http://xxx.com/hls/20191012/085950_49.ts
http://xxx.com/hls/20191012/090001_50.ts
http://xxx.com/hls/20191012/090013_51.ts
http://xxx.com/hls/20191012/090025_52.ts
http://xxx.com/hls/20191012/090037_53.ts
http://xxx.com/hls/20191012/090049_54.ts
http://xxx