fluent-ffmpeg wrong output duration

Viewed 29

I'm trying to stream a video using fluent-ffmpeg and without save it.

I use this code but the output video was cut (12s instead of the 20s of the original video). I tried many output options but without success.

Precision : I want to get the stream duration in the web player.

Thanks a lot for your help !

enter image description here

let imageData = [];

let tmp = {};
tmp.filter = 'overlay';
tmp.inputs = '[0:v][1:v]';
tmp.options = {};
//tmp.options.enable = `between(t,${image.startAt}, ${image.endAt})`;
tmp.options.x = imagePositionX;
tmp.options.y = imagePositionY;
tmp.outputs = 'tmp';
imageData.push(tmp);

let size = await ufs(videoURL);

res.status(206);
res.set('Content-Type', 'video/mp4');

if (req.headers.range) {
  let range        = req.headers.range;
  let parts        = range.replace(/bytes=/, "").split("-");
  let partialstart = parts[0];
  let partialend   = parts[1];

  let start     = parseInt(partialstart, 10);
  let end       = partialend ? parseInt(partialend, 10) : size-1;
  let chunksize = (end-start)+1;

  res.set('Content-Range', 'bytes ' + start + '-' + end + '/' + size);
  res.set('Accept-Ranges', 'bytes');
  res.set('Content-Length', chunksize);
} else {
  res.set('Content-Length', size);
}

let stream = ffmpeg(videoURL)
.input(imageURL)
.videoCodec('libx264')
.audioCodec('aac')
.fps('29.97')
.complexFilter(imageData, 'tmp')
.outputOptions([
  '-movflags frag_keyframe+empty_moov',
  '-frag_duration 100',
  '-pix_fmt yuv420p',
  '-map 0:a?',
  '-b:v 2400k',
  '-b:a 160k',
  '-minrate 200k',
  '-maxrate 1300k',
  '-bufsize 13000k',
  '-f mp4',
])
.on('end', () => {
  console.log('file has been converted succesfully');
})
.on('error', (err) => {
  //console.log('error : ', err)
  console.log('error : ', err.message)
})
.pipe(res, {end: true})
0 Answers
Related