我想用hls视频(m3u8文件)创建服务器,因此,如果我在浏览器http://localhost:4000/stream/video.m3u8中编写,我想获取video.m3u8文件。我尝试了这个,但对我来说live.js不起作用:
var ffmpeg = require('../index');
var HLSServer = require('hls-server')
var http = require('http')
var server = http.createServer()
var hls = new HLSServer(server, {
path: '/streams'
})
server.listen(4000, () => {
console.log('HLSServer ready on htpp://localhost:4000')
})
const command = ffmpeg('https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8')
.outputOptions([
'-hls_time 10',
'-hls_playlist_type event',
`-hls_segment_filename %03d.ts`,
'-hls_base_url http://localhost:4000/'
])
.output('/streams/outputfile.m3u8')
.on('progress', function (progress) {
console.log('Processing: ' + progress.percent + '% done')
})
.on('end', function (err, stdout, stderr) {
console.log('Finished processing!' /*, err, stdout, stderr*/)
// console.log(stdout)
})
.run()
更新:
控制台日志:
HLSServer ready on htpp://localhost:4000
Processing: 1.213% done
Processing: 4.231% done
...
但是文件outputfile.m3u8
却未创建,扩展名为.ts
的文件也没有创建。如果我延迟了'-hls_base_url http://localhost:4000/'
行。文件outputfile.m3u8正在保存在磁盘上(但是VLC仍然无法打开文件...什么都没做)...我想通过在浏览器outputfile.m3u8
中写入来获取http://localhost:4000/streams/outputfile.m3u8
。因为现在我收到404错误(无页面)
UPDATE2: 运行时从控制台记录日志:
ffmpeg.exe -i "https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8" -hls_time 10 -hls_playlist_type event -hls_segment_filename %03d.ts -hls_base_url http://localhost:4000 outputfile.m3u8 -loglevel verbose
在cmd
中:
UPDATE3:
当我将命令更改为:.\ffmpeg.exe -i https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8 -hls_time 10 -hls_playlist_type event -hls_segment_filename %03d.ts -hls_base_url http://localhost:4000 http://localhost:4000/outputfile.m3u8 -loglevel verbose
在日志中我收到错误:URL read error: Error number -10053 occurred