How to use ffmpeg-static - 10 common examples

To help you get started, we’ve selected a few ffmpeg-static examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alex73630 / Floatplane-Downloader / rewrite.js View on Github external
.on('end', function(){
						console.log('\n');
						createdDate = doc.date + 'T00:00:00';

						// Create a metadata object containing important metadatas
						metadata = {
							title: doc.title,
							creation_time: createdDate
						};

						// Set ffmpeg path and arguments then launch it.
						cmd = '"' + ffmpegStatic.path + '"';
						args = ' -i "' + config.plexFolder + videoTypeFolder + doc.filenameTest + '" -y -acodec copy -vcodec copy -metadata title="' + doc.title + '" -metadata creation_time="' + createdDate + '" "' + config.plexFolder + videoTypeFolder + doc.filename + '"';
						exec(cmd + args , function(error,stdout,stderr){
							if (error) {
								// Error while adding metadatas
								console.log('ffmpegError:',error);
								// Delete temporary file
								fs.unlinkSync(config.plexFolder + videoTypeFolder + doc.filenameTest);
							}
							else {
								// Finished to add metadatas
								console.log('ffmpegSuccess for file:',doc.filename);
								// Delete temporary file
								fs.unlinkSync(config.plexFolder + videoTypeFolder + doc.filenameTest);
								// Set video as downloaded
								db.library.update({videoID:doc.videoID},{$set:{downloaded:true}},{},function() {
									downloadedVideos.push(doc.videoID);
github alex73630 / Floatplane-Downloader / index.js View on Github external
.on('end', function(){
    			console.log('\n');
					createdDate = fileJson.date + 'T00:00:00';

					// Create a metadata object containing important metadatas
					metadata = {
						title: fileJson.title,
						show: parsedTypeForTitle,
						creation_time: createdDate
					}

					// Set ffmpeg path and arguments then launch it.
					cmd = '"' + ffmpegStatic.path + '"';
					args = ' -i "' + config.plexFolder + videoTypeFolder + fileJson.filenameTest + '" -y -acodec copy -vcodec copy -metadata title="' + fileJson.title + '" -metadata show="' + parsedTypeForTitle + '" "' + config.plexFolder + videoTypeFolder + fileJson.filename + '"';
					exec(cmd + args , function(error,stdout,stderr){
						if (error) {
							// Error while adding metadatas
							console.log('ffmpegError:',error);
							// Delete temporary file
							fs.unlinkSync(config.plexFolder + videoTypeFolder + fileJson.filenameTest);
							// Move "new" json to "failed" json folder
							fs.renameSync(jsonNewDir + file, jsonFailedDir + file);
							// Send callback to take care of the next json file
							callback();
						}
						else {
							// Finished to add metadatas
							console.log('ffmpegSuccess for file:',fileJson.filename);
							// Delete temporary file
github firebase / functions-samples / ffmpeg-convert-audio / functions / index.js View on Github external
}).then(() => {
    console.log('Audio downloaded locally to', tempFilePath);
    // Convert the audio to mono channel using FFMPEG.
    const command = ffmpeg(tempFilePath)
      .setFfmpegPath(ffmpeg_static.path)    
      .audioChannels(1)
      .audioFrequency(16000)
      .format('flac')
      .on('error', (err) => {
        console.log('An error occurred: ' + err.message);
      })
      .on('end', () => {
        console.log('Output audio created at', targetTempFilePath);

        // Uploading the audio.
        return bucket.upload(targetTempFilePath, {destination: targetStorageFilePath}).then(() => {
          console.log('Output audio uploaded to', targetStorageFilePath);

          // Once the audio has been uploaded delete the local file to free up disk space.     
          fs.unlinkSync(tempFilePath);
          fs.unlinkSync(targetTempFilePath);
github adaptlearning / adapt_authoring / plugins / filestorage / localfs / index.js View on Github external
// LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE
/**
 * Local LocalFileStorage module
 */
const async = require('async');
const ffmpegStatic = require('ffmpeg-static');
const ffprobeStatic = require('ffprobe-static');
const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs-extra');
const path = require('path');
const ffprobe = require('ffprobe');
const util = require('util');

ffmpeg.setFfmpegPath(ffmpegStatic.path);

const configuration = require('../../../lib/configuration');
const FileStorage = require('../../../lib/filestorage').FileStorage;
const logger = require('../../../lib/logger');
const usermanager = require('../../../lib/usermanager');

function LocalFileStorage() {
  this.dataRoot = path.join(configuration.serverRoot, configuration.getConfig('dataRoot'));
}

util.inherits(LocalFileStorage, FileStorage);

/**
 * All paths used in local filestorage are relative to the dataRoot
 *
 * @param {string} relativePath
github Automattic / wp-e2e-tests / lib / video-recorder.js View on Github external
export function startVideo() {
	if ( ! isVideoEnabled() ) {
		return;
	}
	const dateTime = new Date()
		.toISOString()
		.split( '.' )[ 0 ]
		.replace( /:/g, '-' );
	const fileName = `${ global.displayNum }-${ dateTime }.mpg`;
	file = path.resolve( path.join( './screenshots/videos', fileName ) );
	createDir( path.dirname( file ) );
	ffVideo = child_process.spawn( ffmpeg.path, [
		'-f',
		'x11grab',
		'-video_size',
		'1440x1000',
		'-r',
		30,
		'-i',
		':' + global.displayNum,
		'-pix_fmt',
		'yuv420p',
		'-loglevel',
		'error',
		file,
	] );
}
github LeaPhant / flowabot / renderer / render_frame.js View on Github external
async function renderHitsounds(mediaPromise, beatmap, start_time, actual_length, modded_length, time_scale, file_path){
	let media = await mediaPromise;
	let execFilePromise = util.promisify(execFile);

	try{
		await execFilePromise(ffmpeg.path, [
			'-ss', start_time / 1000, '-i', `"${media.audio_path}"`, '-t', actual_length * Math.max(1, time_scale) / 1000,
			'-filter:a', `"afade=t=out:st=${actual_length * time_scale / 1000 - 0.5 / time_scale}:d=0.5,atempo=${time_scale},volume=0.7"`,
			path.resolve(file_path, 'audio.wav')
		], { shell: true });
	}catch(e){
		console.error(e);
		throw "Error trimming beatmap audio";
	}

	let hitSoundPaths = await processHitsounds(media.beatmap_path);

	let hitObjects = beatmap.hitObjects.filter(a => a.startTime >= start_time && a.startTime < start_time + actual_length * time_scale);
	let hitSounds = [];

	hitObjects.forEach(hitObject => {
		let timingPoint = getTimingPoint(beatmap.timingPoints, hitObject.startTime);
github greggman / ffmpegserver.js / lib / ffmpeg-runner.js View on Github external
function FFMpegRunner(args) {
  var emitter = new EventEmitter();
  var spawn = require('child_process').spawn;
  var cmd = ffmpeg.path;

  debug(cmd + '"' + args.join('" "') + '"');
  var proc = spawn(cmd, args);
  var stdout = [];
  var stderr = [];
  var highestFrameNumber = -1;
  var frameNumRE = /frame= *(\d+) /;

  proc.stdout.setEncoding('utf8');
  proc.stdout.on('data', function (data) {
      var str = data.toString()
      var lines = str.split(/(\r?\n)/g);
      stdout = stdout.concat(lines);
  });

  proc.stderr.setEncoding('utf8');
github bouiboui / linear16 / index.js View on Github external
return new Promise((resolve, reject) => {
        try {
            ffmpeg()
                .setFfmpegPath(ffmpeg_static.path)
                .input(filePathIn)
                .outputOptions([
                    '-f s16le',
                    '-acodec pcm_s16le',
                    '-vn',
                    '-ac 1',
                    '-ar 16k',
                    '-map_metadata -1'
                ])
                .save(filePathOut)
                .on('end', () => resolve(filePathOut));

        } catch (e) {
            reject(e);
        }
    });
github kivancguckiran / youtube-to / lib / index.js View on Github external
return new Promise((resolve, reject) => {
		ffmpeg(ytdl(url))
			.setFfmpegPath(binaries.path)
			.format(format)
			.output(stream)
			.on('start', (commandLine) => debug(commandLine))
			.on('stderr', (stderrLine) => debug(stderrLine))
			.on('error', (err) => reject(err))
			.on('end', () => resolve())
			.run();
	});
}

ffmpeg-static

ffmpeg static binaries for Mac OSX and Linux and Windows

GPL-3.0
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis

Popular ffmpeg-static functions