Transcoding in NODEJS using FFMPEG

Posted By : Himanshu Goyal | 15-Mar-2016

Intro:  The fluent-ffmpeg npm module used to perform various opertion like video transcoding ,get video meta data,thumbnail of video ,reduce size of image   etc.Using this module you can convert any transcoding flavour. you first install the ffmpeg and then install the npm module .you can convert with any flavour like 144p,256p,360p,720p etc.

Install procedure

  • sudo apt-get install ffmpeg
  • npm install fluent-ffmpeg 
  • var ffmpeg=require('fluent-ffmpeg')

Code For Video Transcoding:


 ffmpeg("path of file to transfer").fps(25).size(data.height + 'x' + data.width).
videoCodec(data.video_codec).addOption('-strict',  'experimental').
videoBitrate(data.video_bitrate).audioCodec(data.audio_codec).
audioBitrate(data.audio_bitrate).on('error', function (err) {
                      console.log(err)
                    }).on('end', function () {

//code after transcoding

})
 
 

Code For Thumbnail Generation:


   ffmpeg(serverPath).screenshots({
                        count: 1, //number of thumbnail want to generate
                        folder: //path where you want to save
                        filename: timeStamp + '_thumbnail.png',
                        size: '320x240'
                    }).on('end', function () {

})
 

 

About Author

Author Image
Himanshu Goyal

Himanshu is a bright Java ,Mean stack developer and have good knowledge of Hibernate, Spring,FFmepg,Neo4j JSON, Jquery, NODE.JS .His hobbies are learning new things, fitness .

Request for Proposal

Name is required

Comment is required

Sending message..