top of page

How to use FFmpeg tool in Rails Application

  • Writer: Mischelle L
    Mischelle L
  • Feb 1, 2018
  • 1 min read

FFmpeg is an extremely powerful and versatile command line tool for converting any multimedia files. It is free and available for Windows, Mac and Linux machines. Whether you want to join two video files, extract the audio component from a video file, convert your video into an animated GIF, FFmpeg can do it all and even more.

FFmpeg command synopsis

ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...

Some Basic and Useful Commands


  • Cut video file into a smaller clip

ffmpeg -i videoplayback.mp4 -ss 00:00:50 -codec copy -t 20 output.mp4


  • Convert video from one format to another

ffmpeg -i videoplayback.mp4 -c:v libx264 filename.wav


  • Mute a video (Remove the audio component)

ffmpeg -i videoplayback.mp4 -an mute-video.mp4


  • Convert Video into Images

ffmpeg -i videoplayback.mp4 -r 0.25 frames_%1d.png


  • Convert a video into animated GIF

ffmpeg -i videoplayback.mp4 -vf scale=500:400 -r 5 -t 00:00:30 image.gif


  • Add subtitles to a movie

ffmpeg -i videoplayback.mp4 -i subtitles.srt -c copy -c:v libx264 -crf 23 output.mkv

Steps to use FFmpeg commands in Ruby on Rails application:


  • FFmpeg must be installed in the system

  • Create .yml file in application to specify ffmpeg path as environment variable, you will get to know the ffmpeg path using command which ffmpeg in your system

  • You will have to specify ffmpeg command in rails application as system command Example is given below:

Syntax:- system("#{ENV['FFMPEG']} -i input.mp4 output.avi”)

Source: http://www.cryptextechnologies.com/blogs/how-to-use-ffmpeg-tool-in-rails-application

 
 
 

Recent Posts

See All

Comments


© 2023 by Walkaway. Proudly created with Wix.com

  • Facebook Black Round
  • Google+ - Black Circle
  • Twitter Black Round
bottom of page