Ejemplo n.º 1
0
	}).on('end', function(){

		var rgb = new FFmpeg({ source: src });

		rgb.addOption(
			'-vf'
			, '[in] scale=iw:ih,\
			pad=iw:2*ih [top];\
			movie=seethru-tmp-alpha.mov,\
			scale=iw:ih [bottom];\
			[top][bottom] overlay=0:h [out]'
		).withVideoCodec(metadata.streams[0].codec_name);

		if (metadata.streams.length > 1){
			rgb.withAudioCodec(metadata.streams[1].codec_name);
		}

		rgb.on('end', function(){
			fs.unlink('seethru-tmp-alpha.' + intermediateFormat, function(){
				console.log('Processing ' + src + ' finished!');
			});
		}).on('error', function(err){
			console.error('An error occurred combining the video sources: ' + err.message);
			throw err;
		}).saveToFile(argv.out);

	}).saveToFile('seethru-tmp-alpha.' + intermediateFormat);
Ejemplo n.º 2
0
function createVideoCommand(data, streamspec, height, candidates, seekTime) {
	var command = new Ffmpeg({ source: data.source, timeout: 0 });

	if (isNaN(height)) {
		height = data.height;
	}

	// Select streams
	var selectedStreams = addStreamOptions(command, data, streamspec);
	logger.debug("Selected streams: %j", selectedStreams);
	logger.debug("Candidates: %j", candidates);

	var audioStream = selectedStreams.audio;
	var audioCopy = false;

	var videoStream = selectedStreams.video;
	var videoCopy = false;

	if (data.height === height && seekTime === 0) {
		// Attempt to copy video stream
		var videoCopyCandidates = matchVideo(candidates, videoStream);

		if (videoCopyCandidates.length) {
			candidates = videoCopyCandidates;
			videoCopy = true;
		}
	}

	if (seekTime === 0) {
		// Try to copy audio stream
		var audioCopyCandidates = matchAudio(candidates, audioStream);

		if (audioCopyCandidates.length) {
			candidates = audioCopyCandidates;
			audioCopy = true;
		}
	}

	// Use first remaining candidate
	var chosen = candidates[0];
	logger.debug("Chose candidate: %j", chosen);

	if (audioCopy) {
		logger.debug("Can copy audio");
		command.withAudioCodec("copy");
	} else {
		command.withAudioCodec(chosen.acodec);

		var acodecDef = capabilities.acodecs[chosen.acodec];
		if (typeof acodecDef === "object" && "options" in acodecDef) {
			command.addOptions(acodecDef.options);
		}
	}

	if (videoCopy) {
		logger.debug("Can copy video");
		command.withVideoCodec("copy");
	} else {
		command.withVideoCodec(chosen.vcodec);

		if (height !== data.height) {
			command.withSize("?x" + height);
		}

		var vcodecDef = capabilities.vcodecs[chosen.vcodec];
		if (typeof vcodecDef === "object" && "options" in vcodecDef) {
			command.addOptions(vcodecDef.options);
		}
	}

	// Apply provider options
	if (data.options && data.options.length) {
		command.addOptions(data.options);
	}

	// Apply provider filters
	if (data.filters) {
		data.filters.forEach(function(filter) {
			command.withVideoFilter(filter);
		});
	}

	// Apply format and save mimetype
	command.toFormat(capabilities.vformats[chosen.format].format);
	command._nestorMimetype = chosen.format;

	return command;
}