How to install and use ffmpeg + node js with ubuntu

FFmpeg is an open source library which you can use to convert any video or audio into another format, create thumbnails and resize video or audio. In this article I would cover how to install ffmpeg on Ubuntu and use it with nodejs. So lets start.

  1. Install ffmpeg on ubuntu
  2. Create a project with node js
  3. Use of ffmpeg with node js

Install ffmpeg on ubuntu:

For install ffmpeg on ubuntu you needs to follow these steps:

  1. Update the package list with this command
  1. Install ffmpeg with this command
  1. For check ffmpeg is installed or not run this command:

Now ffmpeg is ready to run on your system, the next step is how would we use ffmpeg with node js for covert or manipulate video.

Create project for node js:

Nodejs is the server side javascript environment for creating web applications. For nodejs you need npm to install the nodejs project. For creating a nodejs project you needs to follow these steps:

  1. mkdir foldername
  2. cd /foldername
  3. npm install
  4. npm install express –save

Now create server.js in the root of the project folder. And paste this code in it

And save this file.

Now come on cmd run this command for run application on browser. You can access your application with http://localhost:3000 here 3000 is the port you can use another instead. Your application is ready. Now comes on ffmpeg usage.

How to use ffmpeg with nodejs

For use of ffmpeg you need an npm extension called “node-fluent-ffmpeg”. Firstly you would install this extension follow this command for install it

To start using this you must include it in your project so we would open server.js file and place it on the top of file. And use the code below i have mentioned. It is the easiest way to use the ffmpeg with node js.

That’s it.

Conclusion: This is the tutorial on how to install ffmpeg and use it in nodejs. This is very simple. There is one step I have faced little problem in when including the ffmpeg path. So if you are facing this problem too then you need to check ffmpeg installed directory and change in this code.

Happy learning.

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *