0

index.js

const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg');
const process = require('process');

const args = process.argv.slice(2);
if (args.length !== 4) {
  console.error('Incorrect number of arguments');
  process.exit(1);
}

const startTime = args[0];
const timeDuration = args[1];
const inputFile = args[2];
const outputFile=args[3];

ffmpeg.setFfmpegPath(ffmpegPath);

ffmpeg(inputFile)
  .setStartTime(startTime)
  .setDuration(timeDuration)
  .output(outputFile)
  .on('end', function(err) {
    if(!err) { 
      console.log('conversion Done') 
    }
  })
  .on('error', function(err){
    console.log('error: ', err)
  }).run();

I am running this command on the terminal to generate a clip from the m3u8 file node index.js 00:00:10 46 ./path/sample.m3u8 ./path/output.m3u8

The main problem is that it is not creating a clip for more than 13 seconds. For example, the above command should generate a 46s clip but it is going near 13 seconds. So I don't get what is the issue. Any clip less than 13 works perfectly fine. Is there any way to fix that?

Here is a link to the m3u8 file https://mp4.to/downloads/0cb552cd749c4cf4b

axel
  • 3,778
  • 4
  • 45
  • 72
Alan
  • 21
  • 4
  • is it possible that FFmpeg has a buffer that is getting full? Usually there are some switches in the config files? Maybe node has a buffer? Are all the files created the same size? FFMpeg has this -fs switch that limits the file size, maybe that is it? – Good Lux Jan 13 '21 at 02:06
  • 1
    Set output option: `-hls_list_size 0`. – Gyan Jan 13 '21 at 05:03
  • Thanks, it's working the only issue is that the first ts file it's generating isn't working as it should. the first 3s from the output.m3u8 working like a static picture while playing video and then the video plays smoothly. Is there a way to fix that? so that the first ts file is getting generated works the same as other? here I'm talking about the test0.ts file as output – Alan Jan 13 '21 at 07:27

0 Answers0