HLS Streaming using node JS

前端 未结 1 1463
粉色の甜心
粉色の甜心 2021-02-03 11:51

I\'m trying to stream HLS content using node.js. And somehow it is not working. It\'ll be of great help if someone helps me out.

Problem:- Trying to ser

相关标签:
1条回答
  • 2021-02-03 12:13

    With the idea from Brad, I was able to do this using express.static. Here goes the solution.

    The app.js is changed like this

    var express = require('express');
    var app = express();
    var path = require('path');
    
    app.use(express.static(path.join(__dirname,'streamcontent')));
    
    app.listen(8000);
    console.log('Listening on Port 8000');
    

    and the .m3u8 playlist changed to this

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-MEDIA-SEQUENCE:0
    #EXT-X-ALLOW-CACHE:YES
    #EXT-X-TARGETDURATION:19
    #EXT-X-PLAYLIST-TYPE:VOD
    #EXTINF:12.595922,
    http://localhost:8000/segment0.ts
    #EXTINF:10.135133,
    http://localhost:8000/segment1.ts
    #EXTINF:11.511511,
    http://localhost:8000/segment2.ts
    

    And thats it. Voila !!!

    0 讨论(0)
提交回复
热议问题