Many Windows users already have plenty of applications to download, install, activate one more to work with video. Let's do without all that hassle!
FFmpeg is a functional video and audio converter. It has no graphical interface, so you need to perform operations from the console. At the same time, the program's functionality and the quality of its work exceeds that of conventional converters.
FFmpeg basic features:
file conversion;
resolution change;
framing;
trimming and gluing files;
replace, add, extract audio tracks and subtitles;
watermarking;
encoding or streaming streaming video.
FFmpeg is actually easy to use and will be useful for both professionals working with video and amateurs who decide to process their home video archive.
FFmpeg Installation.
Unzip the contents of the downloaded archive, for example, to Program Files or Windows or Windows\System32 (or another folder where you may have portable programs stored).
To avoid writing a long path to the program every time, for example: C:\Program Files/ffmpeg/bin/ffmpeg.exe. I recommend adding it to the system variable Pathto do so, please go to:
Start → Options → System → About → Advanced System Options → Environment Variables
or
Run "Run" by clicking win+R and execute sysdm.cplthen go to the "Advanced" tab, and there you will find "Environment Variables".
In the User Environment Variables window, double-click on the line Pathwhere you create a new one with the path to the folder with the FFmpeg\bin containing ffmpeg.exe.
Path environment variable
Now, in order to call FFmpeg use the following command in the console (PowerShell or CMD):
ffmpeg.exe -version
If the FFmpeg version message appears in the console, then the program is working! If the message appears: "ffmpeg.exe" is not internal or external command, executable program or batch filethen you should restart your computer.
FFmpeg: video conversion.
After installation FFmpeg you can work with media files, for example, convert video in the console.
ffmpeg -i input.avi output.mp4
This command will convert a video from a file input.avi в output.mp4. The default setting for mov and mp4 files is H.264 codec. The frame size and fps will be taken from the original file.
In the example above, the default settings may be different from your desired settings, so you can set the parameters explicitly.
Additional parameters
-i name of the source file to be converted, if there are several files, you should specify -i before each of them;
-y will answer yes to all questions from FFmpeg if they arise during the encoding process, e.g. to overwrite a file if it already exists;
-vcodec or briefly c:v - video codec settings, or copy (if transcoding is not required), or an empty parameter (default);
-f - container format;
-b:v (-vb, -b) - video bitrate in kilobits or megabits per second is specified by the letter K or M;
-aspect - picture aspect ratio (4:3, 16:9, 1.3333, 1.7777);
-r - frame rate;
-s - resolution, both numeric values (640×480) and letter designations (e.g. qcif, qvga) are supported;
-vf (or -filter:v) - an option with a list of filters that will be applied to the video;
-c:a (or -acodec) - audio codec parameters, or copy (if the audio track is to be left as is), or an empty parameter (default);
-f - audio format;
-af (or -filter:a) - an option with a list of filters to be applied to the audio;
This command will transcode input.avi file to output.mp4. If the output.mp4 file is contained in the destination folder, it will be overwritten (option -y). The codec used will be libx264 with medium speed/quality ratio (-preset medium). The final bitrate is 17000 kbps, the picture aspect ratio is 16:9, and the frame rate is 25 frames per second. AAC with bitrate 128kbps will be used as audio codec.
FFmpeg: Useful commands.
To get information about a video file, follow the steps below: ffmpeg -i video.mp4
To get information about keys and parameters: ffmpeg -help
Source and destination files can be of any format, FFmpeg works with almost all of them. List of supported formats ffmpeg -formats
FFmpeg allows you to trim or cut video into fragments. The -ss option sets the start of trimming, and the -t option sets the duration of the fragment. Time is set in the format "hours:minutes:seconds".
The concat operator is used for gluing. After a colon, it is passed input files separated by a vertical dash. The files to be concatenated must be single format (video and audio), their parameters must match.
Audio files can be converted independently of video.
Changing resolution and cropping
ffmpeg -i input.mp4 -s 1280x720 output.mp4
To change the resolution of the final video you can use the -s option.
Changing resolution and cropping
ffmpeg -i input.mp4 -s 1280x720 output.mp4
To change the resolution of the final video you can use the -s option. However, using the scale filter will give a better result.
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4
The crop filter is intended for cropping the image. Its parameters have the following form crop=w:h:x:y, where w is the width of the rectangle to be cropped from the source video, h is the height of the rectangle, x and y are x-coordinates of the cropping start point.
The -ar option specifies the sampling rate, -ac specifies the number of channels, and -ab specifies the bitrate. The -vn option means that video information will be discarded, and the -f option indicates the format of the resulting file (mp3 in the example).
If there are several audio tracks, to save a separate audio track from a video file (demultiplexing) use the -map option and specify its stream ID.
ffmpeg -i input.avi -map 0:2 audio.wav
The example below shows how to add multiple audio tracks to a video file (multiplexing).