Parixit Jani     Aug,09 2017

Convert Audio-Video files into Mp3 Audio and Mp4 Video using FFMPEG Commands

Just recently there was a requirement to convert several audio files extensions into Mp3 Audio and several video files extensions into Mp4 Video for one of the web application project.

 

Initially, searched to find best available multimedia frameworks to meet the requirement. But ultimately just got along with FFMPEG multimedia framework which provides command line tool to convert audio-video files extensions into Mp3 Audio and Mp4 Video.

 

The best command line tool I found to fit my requirement is FFMPEG. It is the command line multimedia framework which can be used to encode, decode, transcode, play etc. As FFMPEG suggest it run over Linux, windows and some other environments and configurations.
 
Mp4 Video Converter
 
It is a fast video and audio converter that can also grab from a live audio/video source. It can convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter.
 
Now, let's see further what commands I have used :
----------------------------------------------------------------------------------------------------------
  1. FFMPEG command to convert Audio files to mp3.
  • Single File Convert

  • ​​Command Options
    • -nostats : This option will not print progress/statistics on console.
    • -loglevel (panic|fatal|error|warning|info) :  This options only shows fatal errors which may crash the process.
    • -y : This option will overwrite output file without confirmation.
    • -i : This option indicate the input file.
    • -codec:a : This option indicate the audio codec. codec is the computer program for encoding or decoding the digital data stream or signal.
    • -libmp3lame : To convert a file to mp3, you need to enable the LAME support. You can enable by this option.
    • -qscale:a : This option is used for quality scale. a after(:) is stream_specifier.
 
  • Merge Multiple Files (Below shell script code is use to convert and merge multiple audio files in to one file [.mp3])

----------------------------------------------------------------------------------------------------------

  1. FFMPEG command to convert Video files to mp4.
  • Single File Convert

  • Command Options
    • -deinterlace : If you use this option then it may introduces some losses input file. 
    • -pix_fmt : This refer pixel format.
    • -yuv420p : This is most common format as data is more easily compressed.
    • -an : This option is used to remove the audio from the output file.
    • -scale : To scale output video.
    • -libx264 : This is software lib to encoding streams
    • -threads : No of thread to encode data. in this case its 0.

 

  • Merge Multiple Files (Below shell script code is use to convert and merge multiple files in to one file [.mp4])

----------------------------------------------------------------------------------------------------------

All the command here I used to process either Audio or Video files can be working fine to convert and to merge in extensions like (avi,mp4,mpeg,flv,wmv,3g2,3gp,mpg,mkv,mov,mod,mp3,wav,m4a,3gp,wma). 

 

Looking to explore more about FFMPEG, here is the download link to download FFMPEG. There are plenty of documentation resources available on site for multimedia command line tools.