node.js - How to stream mp4 file with fluent-ffmpeg? -


i trying stream video file fluent-ffmpeg. could't it. here code

var filepath = null; filepath     = "video.mp4";  var stat  = fs.statsync(filepath);  var range        = req.headers.range; var parts        = range.replace(/bytes=/, "").split("-"); var partialstart = parts[0]; var partialend   = parts[1];  var start     = parseint(partialstart, 10); var end       = partialend ? parseint(partialend, 10) : total-1; var chunksize = (end-start)+1;  var file = fs.createreadstream(filepath, {start: start, end: end});  res.writehead(206, {  'content-range  ': 'bytes ' + start + '-' + end + '/' + total,  'accept-ranges'  : 'bytes',  'content-length' : chunksize,  'content-type'   : 'video/mp4' });  ffmpeg(file) .videocodec('libx264') .withaudiocodec('aac') .format('mp4') .videofilters({  filter: 'drawtext',  options: {   fontsize:20,   fontfile: 'public/fonts/roboto-black.ttf',   text: "username",   x:10,   y:10,   fontcolor:"red"  }})  .outputoptions(['-frag_duration 100','-movflags frag_keyframe+faststart','-pix_fmt yuv420p'])  .output(res,{ end:true })  .on('error', function(err, stdout, stderr) {   console.log('an error happened: ' + err.message + stdout + stderr);  })  .run(); 

when run code block, video not playing , throws error:

an error happened: ffmpeg exited code 1: pipe:0: invalid data found when processing input 

when not use stream input, video playing in chrome after little time, video player throws error.

is there way can show text while playing video ffmpeg or without it?


Comments

Popular posts from this blog

c# SetCompatibleTextRenderingDefault must be called before the first -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -

c++ - Fill runtime data at compile time with templates -