node-m3u8stream icon indicating copy to clipboard operation
node-m3u8stream copied to clipboard

I am not a Typescript coder but I made it so you can use ranges and encrypted files

Open agamemnus opened this issue 6 years ago • 2 comments

Here is my code:

https://github.com/agamemnus/node-m3u8stream/tree/master/lib I modified index.ts (index.js) and m3u8-parser.ts (m3u8-parser.js)

I can't be bothered to try to make it work with Typescript -- just throwing it out there for anyone else.

agamemnus avatar Oct 02 '19 21:10 agamemnus

Thanks @agamemnus. It seems, the stream gets decrypted when parsing is done and when options.parseComplete is set. What is options.parseComplete and where it should be set/how? And the HLS spec says, that each fragment can be encrypted, so I guess it is better when the decryption is done in the streamQueue or?

tejado avatar Jan 12 '20 22:01 tejado

Well, "parseComplete" is the callback. I don't know about the answer to your last question. To be honest, I don't even remember what I did.

Here is my code, using the library/plugin (the "converter" variable is "video-converter" on npm):

    function keepGoing (m3u8Path) {
     mkdirp(outputDirectory, function (err) {
      if (err) reject(err)
      let stream = m3u8stream(m3u8Path, {parseComplete: parseComplete})
     
      function parseComplete (newStream) {
       let writeStream = fs.createWriteStream(outputDirectory + '/full.mp4', {autoClose: false})
       var streamPipe = newStream.pipe(writeStream)
       
       streamPipe.on('finish', function () {
        progress.log('Audio downloaded.')
        var filenameFull = outputDirectory + '/full.mp4'
        converter.convert(outputDirectory + '/full.mp4', outputFile, function (err) {
         if (err) throw err
         progress.log('Audio combined.')
         resolve(outputFile)
        })
       })
      }
     })
    }

agamemnus avatar Jan 13 '20 00:01 agamemnus