Carol Carol - 9 months ago 74
Node.js Question

HLS from node to iOS app

I created a API in node that you can upload a video (.mp4, .avi, etc). Then, the video is request by a iOS app in swift.

I would like to use HTTP Live streaming from the app. Can you help me how can I transform the video file to chunks .ts and generate the playlist file (m3u8) to be consumed by the app?

This is the correct flow?
What it's the best solution?


Answer Source

Finally I have a solution, I use fluent-ffmpeg like this :

var ffmpeg = require('fluent-ffmpeg');

ffmpeg(video, { timeout: 432000 })
    .addOption('-level', 3.0)
    // size
    // start_number
    .addOption('-start_number', 0)
    // set hls segments time
    .addOption('-hls_time', 10)
    // include all the segments in the list
    .addOption('-hls_list_size', 0)
    // format -f
    // setup event handlers
    .on('start', function(cmd) {
       console.log('Started ' + cmd);
    .on('error', function(err) {
      logger.error('an error happened: ' + err.message);
    .on('end', function() {
       logger.debug('File has been converted succesfully');