JosePedroDias/webcam2hls

How to get the duration of the webm video?

deendoughouz opened this issue · 3 comments

The first part of the video 00001.ts is created fine, but other files are broken, I found it due ffmpeg is returning the duration of the video.

Anyway to fix it?

I modified the findVideoDuration method in videoUtils.js to this and it worked well
`function findVideoDuration(fp, cb) {
var out = [];

// var args = [
// 	FFMPEG_DIR + 'ffprobe',
// 	'-v', 'quiet', // less verbose
// 	'-print_format', 'json', // output json
// 	'-show_format', // return format info
// 	// '-show_streams',
// 	fp
// ];

var args = [ FFMPEG_DIR+'ffmpeg', '-i', fp,'-progress','-', '-f', 'null', '-'];

console.log(args.join(' '));

var cmd = args.shift();

var proc = child_process.spawn(cmd, args);

proc.stdout.on('data', function(data) {
	out.push( data.toString() );
	//console.log("ondata",data.toString());
});


proc.stderr.on('data', function(data) {
	out.push( data.toString() );
	//console.log("onerrr",data.toString());
});

proc.on('close', function() {
	//console.log('close');
	//console.log("close",out);
	out = out.join('');

	out = parseInt(out.match(/out_time_ms=(.*)\n/)[1])/1000000;

	console.log("duration new = "+out);
	var d = out;

	cb(null, d);
});

}`

@thekirankumar Thanks a a lot, it works for me.

@thekirankumar Thanks a a lot, it works for me.

You are welcome