mp4-mjpeg icon indicating copy to clipboard operation
mp4-mjpeg copied to clipboard

Output videos not playing

Open talltyler opened this issue 5 years ago • 2 comments

Am I using this incorrectly?

const mjpeg = require('./index.js');
const fs = require('fs');

function pad(number) {
  if (number<=999) { number = ("00"+number).slice(-3); }
  return number;
}

mjpeg({ fileName: "output.mp4" })
	.then( (recorder) => {
		console.log('start');
		let current = 1;
		function next() {
			fs.readFile('./images/image-'+pad(current)+'.jpg', function (err, data) {
			  if (err) throw err;
			  recorder.appendImageBuffer( data );
				if (++current <= 10) {
					next();
				} else {
					recorder.finalize()
						.then( () => {
							console.log('MP4 video file is ready');
						})
						.catch( (error) => {
							console.log('error', error);
						})
				}
			});
		}
		next();
	})
	.catch( (error) => {
		console.log('error', error);
	})

From my understanding this is how you intend this library to work but the output isn't playable in any video player that I have. Am I missing something or setting this up in some incorrect way? Is there something special I need to do to the jpg files that I am loading maybe?

talltyler avatar Jan 31 '20 18:01 talltyler

the output isn't playable in any video player that I have

same here, however ffmpeg is able to convert the output into playable file, which means it is missing codec problem.

makc avatar Apr 14 '20 03:04 makc

BTW, the file does play in VLC on Windows with CCCP installed. However, MPC-HQ does not play it on the same machine. So the players support is basically non-existant.

makc avatar Apr 14 '20 04:04 makc