What is @ffmpeg-installer/linux-x64?
@ffmpeg-installer/linux-x64 is an npm package that provides a precompiled FFmpeg binary for Linux x64 systems. It allows developers to easily include FFmpeg in their Node.js projects without needing to compile it from source. FFmpeg is a powerful multimedia framework that can decode, encode, transcode, mux, demux, stream, filter, and play almost anything that humans and machines have created.
What are @ffmpeg-installer/linux-x64's main functionalities?
Video Conversion
This feature allows you to convert video files from one format to another. The code sample demonstrates converting an MP4 file to an AVI file using the FFmpeg binary provided by the package.
const ffmpegPath = require('@ffmpeg-installer/linux-x64').path;
const { exec } = require('child_process');
exec(`${ffmpegPath} -i input.mp4 output.avi`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`Stdout: ${stdout}`);
});
Audio Extraction
This feature allows you to extract audio from a video file. The code sample demonstrates extracting the audio from an MP4 file and saving it as an MP3 file.
const ffmpegPath = require('@ffmpeg-installer/linux-x64').path;
const { exec } = require('child_process');
exec(`${ffmpegPath} -i input.mp4 -q:a 0 -map a output.mp3`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`Stdout: ${stdout}`);
});
Video Compression
This feature allows you to compress video files to reduce their size. The code sample demonstrates compressing an MP4 file using the H.265 codec with a constant rate factor (CRF) of 28.
const ffmpegPath = require('@ffmpeg-installer/linux-x64').path;
const { exec } = require('child_process');
exec(`${ffmpegPath} -i input.mp4 -vcodec libx265 -crf 28 output.mp4`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`Stdout: ${stdout}`);
});
Other packages similar to @ffmpeg-installer/linux-x64
fluent-ffmpeg
fluent-ffmpeg is a Node.js library that provides a fluent API for working with FFmpeg. It allows you to perform various FFmpeg operations such as video conversion, audio extraction, and video compression with a more user-friendly syntax. Unlike @ffmpeg-installer/linux-x64, fluent-ffmpeg does not include the FFmpeg binary itself, so you need to have FFmpeg installed on your system.
ffmpeg-static
ffmpeg-static is an npm package that provides static binaries for FFmpeg across different platforms, including Linux, Windows, and macOS. It is similar to @ffmpeg-installer/linux-x64 in that it includes the FFmpeg binary, but it supports multiple operating systems, making it more versatile for cross-platform development.
node-ffmpeg
node-ffmpeg is a Node.js module that provides a simple interface for using FFmpeg. It allows you to perform various multimedia processing tasks such as video conversion, audio extraction, and video compression. Unlike @ffmpeg-installer/linux-x64, node-ffmpeg requires you to have FFmpeg installed on your system.
Do not use directly, use ffmpeg-installer:
npm install --save @ffmpeg-installer/ffmpeg