I am working on an FFMPEG on node js. I'd like to retrieve the audio track from a video file using node js. I would also like to save such file but I can't figure out how.
I though this line of code would help me :
ffmpeg('/path/to/file.avi').noVideo();
I have got this in npm package. I don't quite understand how to work with this and how to actually save the audio file.
Some other line of code that come in play :
try {
var process = new ffmpeg('/path/to/your_movie.avi');
process.then(function (video) {
// Callback mode
video.fnExtractSoundToMP3('/path/to/your_audio_file.mp3', function (error, file) {
if (!error)
console.log('Audio file: ' + file);
});
}, function (err) {
console.log('Error: ' + err);
});
} catch (e) {
console.log(e.code);
console.log(e.msg);
}
My question is:
How do I retrieve the audio from a FFMPEG video ? How do I save it ?
I would do it like:
just make sure
ffmpeg
is installed and is part of system path, also make sure all the necessary codes are present.Update:
for video without audio, simply do
.noAudio().videoCodec('copy')
:Update 2:
for merging video and audio into single: