Open lanbin45 opened 6 years ago
首先看一下 ./media/live/1/ 下有没有生成相应的m3u8, ts文件 访问的地址是 : http://localhost:8000/live/1/index.m3u8
如果没有生成文件,请注意看配置中 trans -> tasks -> ac:'aac' ,这是个坑,README里并没有说明为什么是aac, 在ffmpeg老版本中,不能直接用aac编码器,因此调用失败,需要至少3.0以上的版本。这个参数是给flash推流nellymoser音频编码转aac,来实现HLS流有声的。 如果推流本来就是aac的,那这个地方改为 copy就好了。
@illuspas 非常感谢您的及时回复; 我的ffmpeg版本是
ffmpeg version N-91481-gb8c4d2b2ed
上官网查了一下,是18年7月中旬的版本,应该符合您说的3.0版本以上;我查 ./media/live/1/
文件夹下面确实没有呀生成m3u8, ts类型文件
我把trans.tasks.ac改为copy,生成了ts文件,但是我使用 SRS播放器 在线播放,上述的这几个url:
http://localhost/live/1/index.m3u8
, http://localhost:8000/live/1/index.m3u8
,
http://localhost/media/live/1/index.m3u8
和 http://localhost:8000/media/live/1/index.m3u8
这几个都没有办法播放。 我url对着呢吗?
正常生成了 ts和m3u8文件 那就已经可以播放了 地址规则是: http://localhost:8000/live/1/index.m3u8
我也遇到了同样的问题,推hls时,media/live
文件夹下生成了许多空文件夹,播放也无效,求解
http: {
port: 3001,
allow_origin: '*',
webroot: './public',
mediaroot: './media'
},
trans: {
ffmpeg: 'xxxxx\\ffmpeg.exe',
tasks: [
{
app: 'live',
ac: 'copy',
hls: true,
hlsFlags: '[hls_time=2:hls_list_size=3:hls_flags=delete_segments]',
dash: true,
dashFlags: '[f=dash:window_size=3:extra_window_size=5]'
}
]
}
ffmpeg -re -i liechang.mp4 -c:v libx264 -vcodec copy -f hls rtmp://localhost:8081/live/test
我使用作者推荐的快直播android SDK推流到
rtmp://localhost/live/1
, 使用videojs和在线播放器也都能拿到RTMP Stream并播放。 现在我想要增加一个HLS转流功能,来做手机端网页播放。我参照README配置了HLS转流,详细的config见下面code snippet:http的mediaRoot和ffmpeg路径也修改过了。我试了在
http://localhost/live/1/index.m3u8
和http://localhost:8000/live/1/index.m3u8
无法拿到视频流数据。接着我debug到
node_trans_session.js
里,看到outPath是./media/live/index.m3u8
,所以我又尝试了http://localhost/media/live/1/index.m3u8
和http://localhost:8000/media/live/1/index.m3u8
,也是无法获取视频流。我自己大概理解了一下代码,作者应该是通过FFMPEG将RTMP流转成HLS流(trans中的任务大致都是这个逻辑?) 我想请问一下,我应该怎么获得HLS流?