FFMPEG is a free video Converter. An open source library, that convert’s most popular file formats. Its only drawback is that it needs higher developer effort to reach usable solutions. If we proceed with FFMPEG, we can easily create a better cross platform application for hosting on Windows or Linux servers, and that would be free.
FFMPEG is a complete, cross platform command line tool that is capable of converting, recording and streaming digital audio and video in various formats. It is used to do many multimedia tasks quickly and efficiently like audio compression, audio/video format conversion, images extraction from a video and many more.
FFMPEG Process Overview –
FFMPEG used a decoder and also an encoder, enabling it to convert files from one container or codec combo to a different one. For example, a VOB file from a DVD with MPEG video and AC3 sound can be converted to an AVI file featuring H263 video with MP3 audio, or a QuickTime file with SVQ3 video and MP3 audio can turn into 3GP file with H263 video and AMR wideband sound. The first container is looked at and encoded data is extracted and then fed through the codecs. Newly decoded information is then sent through the end codecs to a new container.
FFMPEG carries an enormous set of features; here are some of the most common ones:
- Encoder – supports encoding into such standards as H.264, MPEG-4, MPEG-2, and many others. Many audio encoding formats are available as well.
- Transcoder – convert from one standard to another. For example, you can create an MPEG-4 video file from an MPEG-2 file.
- Decoder – decode and play video files
- IP Streamer and DVB Analyzer
Useful FFMPEG Commands
FFMPEG supports all popular audio and video formats. We can running the command “/FFMPEG–formats” to get a list of every format that is supported by ourFFMPEG installation.
Here are some commands that will give a good idea of the capabilities of this tool.
- Cut video file into a smaller clip – Use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.
FFMPEG -i input.mp4 -ss 00:00:50.0 -codec copy -t 20 output.mp4
2. Split a video into multiple parts – If we want to split a large video into multiple smaller clips without re-encoding, FFMPEG can help. This command will split the source video into 2 parts – one ending at 50s from the start and the other beginning at 50s and ending at the end of the input video.
FFMPEG -i video.mp4 -t 00:00:50 -c copy small-1.mp4 -ss 00:00:50 -codec copy small-2.mp4
3. Convert video from one format to another – Use the -vcodec parameter to specify the encoding format to be used for the output video. Encoding a video takes time but you can speed up the process by forcing a preset though it would degrade the quality of the output video.
FFMPEG -iyoutube.flv -c:v libx264 filename.mp4
FFMPEG -i video.wmv -c:v libx264 -preset ultrafast video.mp4
4. Join (concatenate) video files – If we have multiple audio or video files encoded with the same codecs, you can join them into a single file using FFMPEG. Create an input file with a list of allsources that you wish to concatenate and then run this command.
FFMPEG -f concat -i file-list.txt -c copy output.mp4
5. Mute a video (Remove the audio component) – Use the -an parameter to disable the audio portion of a video stream.
FFMPEG -i video.mp4 -an mute-video.mp4
6 .Extract the audio from video – The -vn switch extracts the audio portion from a video and we are using the -ab switch to save the audio as a 256kbps MP3 audio file.
FFMPEG -i video.mp4 -vn -ab 256 audio.mp3
7. Extract image frames from a video – This command will extract the video frame at the 15s mark and saves it as an 800px wide JPEG image. We can also use the -s switch (like -s 400×300) to specify the exact dimensions of the image file though it will probably create a stretched image if the image size doesn’t follow the aspect ratio of the original video file.
FFMPEG -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 image.jpg
8. Convert Video into Images – Use FFMPEG to automatically extract image frames from a video every ‘n’ seconds and the images are saved in a sequence. This command saves image frame after every 4 seconds.
FFMPEG -i movie.mp4 -r 0.25 frames_%04d.png
9. Resize a video – Use the size (-s) switch with FFMPEG to resize a video while maintaining the aspect ratio.
FFMPEG -i input.mp4 -s 480×320 -c:a copy output.mp4
10. Crop an audio file – This will create a 30 second audio file starting at 90 seconds from the original audio file without transcoding.
FFMPEG -ss 00:01:30 -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3
11. Change the audio volume – Use the volume filter to alter the volume of a media file using FFMPEG. These commands will half the volume of the audio file.
FFMPEG -i input.wav -af ‘volume=0.5’ output.wav
12. Rotate a video – This command will rotate a video clip 90° clockwise. We can set transpose to 2 to rotate the video 90°anti-clockwise.
FFMPEG -i input.mp4 -filter:v ‘transpose=1’ rotated-video.mp4
This will rotate the video 180° counter-clockwise.
FFMPEG -i input.mp4 -filter:v ‘transpose=2,transpose=2’ rotated-video.mp4
13. Speed up or slow down the video – We can change the speed of our video using the setpts (set presentation time stamp) filter of FFMPEG. This command will make the video 8x (1/8) faster or use setpts=4*PTS to make the video 4x slower.
FFMPEG -i input.mp4 -filter:v “setpts=0.125*PTS” output.mp4
14. Speed up or slow down the audio – For changing the speed of audio, use the atempo audio filter. These commands will double the speed of audio. You can use any value between 0.5 and 2.0 for audio.
FFMPEG -iinput.mkv -filter:a “atempo=2.0” -vnoutput.mkv
Free Download – Click
Available for -Windows, OSX, and Linux.