Node-Media-Server
Node-Media-Server copied to clipboard
HLS流播放问题
我使用作者推荐的快直播android SDK推流到rtmp://localhost/live/1 , 使用videojs和在线播放器也都能拿到RTMP Stream并播放。
现在我想要增加一个HLS转流功能,来做手机端网页播放。我参照README配置了HLS转流,详细的config见下面code snippet:
const config = {
rtmp: {
port: 1935,
chunk_size: 30000,
gop_cache: true,
ping: 60,
ping_timeout: 30
},
http: {
port: 8000,
webroot: './public',
mediaroot: './media',
allow_origin: '*'
},
https: {
port: 8443,
key: './privatekey.pem',
cert: './certificate.pem',
},
auth: {
api: true,
api_user: 'admin',
api_pass: 'admin',
play: false,
publish: false,
secret: 'nodemedia2017privatekey'
},
trans: {
// ffmpeg: '/usr/bin/ffmpeg',
ffmpeg: 'C:\\ffmpeg\\bin\\ffmpeg.exe',
tasks: [
// {
// app: 'live',
// ac: 'aac',
// mp4: true,
// mp4Flags: '[movflags=faststart]',
// },
{
app: 'live',
ac: 'aac',
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]'
}
]
},
}
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流?
#120