FFmpeg detailed instructions. FFMPEG and FFServer for Windows - Brief Instruction

In the past, I told how to install.

In this post, I will consider basic commands that will greatly facilitate work with FFMPEG. A huge amount of information is contained in manuals, they are known to roll, so if some information was outside the post, "man ffmpeg" to help you.

For understanding, simpler structures, such as this:

FFMPEG -SS 5 -i A.Mp4 -Spect 4: 3 -F Image2 -R 1 -VFrames 300 A% 2D.jpg

just below, I will list the most frequently used options.

FFMPEG options

Consider some useful options (in brackets examples). If any options are not specified, the FFMPEG will substitute them from the default values:

-I. - Specifies the name of the source (input) file.
-Threads. - Numeric value, determines the number of processor cores. What, of course, is reflected in the speed of coding and operations on files. Number 0 sets automatic determination of the available nuclear number ( -Threads 2.).
-t. - Specifies the duration of the encoded video in the entire seconds or in the CHC format: mm: ss.
-ss. - Specifies the position in the video file with which coding will begin. Format for whole seconds or CC: mm: ss.
-fs. - Numeric value in bytes, kilobytes (k), megabytes (M). The console register is important. Limits the size of the destination file. Useful for experiments over a small piece of video file so as not to encode the entire file ( -FS 5M.).
-y - This option overwrites existing files without a confirmation request.
Video options:
-Vcodec. - video codec, which will be encoded video ( -Vcodec MPEG4).
-Vpre.- Select the preset for the video codec. First, FFMPEG looks for the preset files in ~ / .Ffmpeg, then in / usr / share / ffmpeg or / usr / local / share / ffmpeg, depending on the installation path. To see what preset files are present, it is possible for the same paths.
-f. - Force, specify the forcibly format of the destination file ( -f avi.).
-b. - Bitrate of video stream. Default: 200kb / s ( -B 1500.).
-bt. - Tolerance of bitrate. Default: 4000K. With two-pass coding, it indicates how far in the first pass can be devaway from the specified average bit rate. The value is not associated with the minimum / maximum bit rate. A too strong decline in this parameter has a negative impact on the quality.
-r. - Number of frames per second. Default: 25 ( -R 15.).
-s. - Frame size, that is, the resolution of the output video file. The default is determined by the source file size. Can be set by invoking abbreviations, for example sVGA Means size 800 × 600. You can view all available reductions in mAN FFMPEG.. (-s 640 × 480 or -s VGA.).
--Spect - numeric values, determines the aspect ratio of the output file ( -Spect 4: 3 or -Spect 1.3333.).
-Croptop.
-Cropbottom
-Cropleft.
-cropright - Crouching frames from above, bottom, left, right. Values \u200b\u200bare indicated in pixels. It can be used, for example, to remove ferrous strips ( -CropTop 15.). In some versions of FFMPEG, these options can be removed and the option is used instead. -VF Crop \u003d Width: Height: x: Y. Read more about it in the relevant section below.
-Pass - the number of passes when encoding, 1 or 2 ( -Pass 2.).
-G. - Size framework, after which the key frame is followed. for example -G 300.installs one key frame every 10 seconds, at the speed of the original video file 29.97fps. 30 frames per second * for 10 seconds \u003d value of the option 300 (approximate value for a DVD-file rip). The smaller the bitrate and the number of frames per second, the less this value should be.
-Deinterlace. - removal of "combs".
Audio Options:
-ar. - Sets the sound sampling frequency. Default: 44100Hz ( -Ar 22050).
-ab. - Bitrate of the soundtrack. Default: 64KB ( -AB 256K.).
-AC. - Number of sound track channels. By default, for incoming streams, this value is 1, for outgoing equal to the number of channels of the source file. In other words, if you make a sound capture, then the number of channels by default 1, and if you take the sound from the video file, for example, the number of channels by default will be equal to the source ( -Ac 2.).
-an. - video encoding without sound track.
-acodec. - audio codecs that sound encoding ( -Acodec Flac).
-APre - A set of presets for audio codec.

The most commonly used structures:
1. Receive information about the video file

Ffmpeg -i video.avi.

2. Turn a set of pictures in video

Ffmpeg -f image2 -i image% d.jpg video.mpg

This command converts all the pictures from the current directory (called image1.jpg, image2.jpg, etc.) in Video.MPG video


FFMPEG -R 12 -Y -i "Image_% 010d.png" output.mpg


Here the Frame Rate (12) is set for the video, the format "image_% 010d.png" means that the pictures will be signed in the form of image_0000000001.png, image_0000000002.png, etc., that is, in PrintF format)

3. Cut the video on the pictures

Ffmpeg -i video.mpg image% d.jpg

This command will create image1.jpg files, image2.jpg, etc., the same PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI formats are supported.
4. Convert video to iPod / iPhone format

Ffmpeg -i source_video.avi input -codec AAC -ab 128KB -Vcodec MPEG4 -B 1200KB -MBD 2 -Flags + 4MV + TELL -AIC 2 -cmp 2 -Subcmp 2 -S 320x180 -title x Final_Video.mp4

Explanations:

  • Source: Source_Video.avi.
  • Audio codec: AAC
  • Audio bitrate: 128KB / S
  • Video codec: MPEG4
  • Video Bitrate: 1200KB / S
  • Video Size: 320 per 180 pixels
  • VIDEO VIDEO: Final_Video.mp4

5. Convert video to PSP format

FFMPEG -I Source_Video.avi -B 300 -S 320x240 -Vcodec XVID -AB 32 -Ar 24000 -ACODEC AAC Final_Video.mp4

Ffmpeg - a tool that can help you convert virtually any audio and video file from command line. This article wrote some useful FFMPEG commands that you need to know for this. The FFMPEG program is an extremely powerful and versatile command line tool for converting audio and video files. The program is free and available for Windows, and Mac and Linux machines. Do you want to merge two video files, extract audio components from video files, convert video to animated GIF, FFMPEG can do it all and even more.

Useful FFMpeg commands

FFMPEG supports all popular audio and video formats. Or you can command ./ffmpeg -formats. To get a list of each format supported by your installed version FFMPEG. If you just started, here are a few teams that will give you a good idea of \u200b\u200bthe possibilities of this tool.

1. Cut the video file to smaller clips

You can use the time difference (-ss) to specify the initial time stamp in the CC format: mm: SS. MC A-T format Parameter to indicate the actual clip duration in seconds.

2. split video into several parts

If you want to divide a big video file to several small clips without re-coding, FFMPEG can help. This command will separate the original video on 2 parts - one ends on 50s from the beginning. And the other, starts with 50s and ends at the end of the input video signal.

3. Convert video from one format to another

You can use the VCodec parameter to specify the format encoding to be used to display the video. Video coding takes a lot of time, but you can speed up the process, forcing the workpiece at least worsen the quality of the output video.

Ffmpeg -i youtube.flv -c: v Libx264 filename.mp4 ffmpeg -i video.wmv -c: v libx264 -preset ultrafast video.mp4

4. Combine (merge) video files

If you have several audio or video files encoded using the same codecs, you can combine them into one file using FFMPEG commands. Create an input file with a list of all source files you want to merge, and then execute this command.

FFMPEG -F Concat -i File List.txt -c Copy Output.mp4

5. Disable video (Delete audio component)

Use this parameter to turn off the sound part of the video stream.

Ffmpeg -i video.mp4 -an mute-video.mp4

6. Extract audio from video

The VN switch retrieves the audio track from the video, and we use - AB switch to save the sound as 256 block / MP3 audio file.

Ffmpeg -i video.mp4 -VN -B 256 audio.mp3

7. Convert video to animated gif file

FFMPEG is an excellent tool for converting video files to animated GIF files, and quality is rather not bad. Use the filter scale to set the GIF image width, parameter T for a specific duration, and the R parameter sets the frame rate (FPS).

Ffmpeg -i video.mp4 -vf scale \u003d 500: -1 -t 10 -r 10 image.gif

8. Extract image frames from video

This command removes a 15s video frame and saves it as 800px wide image width in jPEG format. You can also use the parameter S (400 × 300) by specifying the exact dimensions of the image to the file, although it is likely to create an extensive image if the image size does not match the proportion of the original video file.

Ffmpeg -ss 00:00:15 -i video.mp4 -vf scale \u003d 800: -1 -vframes 1 image.jpg

9. Convert video in images

You can use FFMPEG to automatically extract image frames from video each 'N' seconds and save images in the sequence. This command saves the frame image every 4 seconds.

FFmpeg -i Movie.mp4 -R 0.25 Frames_% 04d.png

10. Merge audio and video files

You can also specify the shortest switch to complete the encoding when the shortest clip ends.

Ffmpeg -i video.mp4 -i audio.mp3 -c: V Copy -c: A AAC -Strict Experimental Output.mp4 ffmpeg -i video.mp4 -i audio.mp3 -c: V Copy -c: A AAC -Strict Experimental -shortest output.mp4

11. Amend the size of the video

Use the size switch to resize the video, while maintaining its proportion.

Ffmpeg -i input.mp4 -s 480x320 -c: A Copy Output.mp4

12. Create a video slideshow from images

This command is used to create a video slideshow using a series of pictures that are named as img001.png, img002.png, etc. Each image will have a duration of 5 seconds (-R 1/5).

FFmpeg -R 1/5 -i IMG% 03D.PNG -C: V LIBX264 -R 30 -PIX_FMT YUV420P Slideshow.mp4

13. Add a poster images for audio

You can add an image to an audio file, and the length of the output video will be the same as the input audio stream. It can be useful for downloading MP3 files on YouTub.

FFmpeg -loop 1 -i image.jpg -i audio.mp3 -c: V LIBX264 -C: A AAC -Strict Experimental -B: A 192K -shortest Output.mp4

14. Convert one image in video

Use the T parameter to specify the duration of the video.

FFmpeg -loop 1 -i Image.png -c: V Libx264 -t 30 -pix_fmt yuv420p video.mp4

15. Add subtitles to the film

This command will create subtitles with files.srt. FFMPEG can also decode the most common subtitle formats.

Ffmpeg -i movie.mp4 -i subtitles.srt -map 0 -map 1 -c Copy -C: V LibX264 -CRF 23 -Preset Veryfast Output.mkv

16. Crop audio file

This will create a 30 second sound file.starting from 90 seconds from the original audio file without transcoding.

17. Changing the sound volume

You can use the Volume Filter to change the volume of the media file using the FFMPEG command. This command will be half reduced the volume of the audio file.

Ffmpeg -i input.wav -af "Volume \u003d 0.5" output.wav

18. Rotate video

This command will rotate the video 90 ° clockwise. You can set the transposition to 2 to rotate the video 90 ° counterclockwise.

Ffmpeg -i input.mp4 -filter: v "transpose \u003d 1" rotated-video.mp4

This command will rotate the video 180 ° counterclockwise.

Ffmpeg -i input.mp4 -filter: v "transpose \u003d 2, transpose \u003d 2" rotated-video.mp4

19. Speed \u200b\u200bup or slow down video

You can change the video speed when using the SetPTS filter (in the electronic form of the time stamp). This command will make the video 8x (1/8) faster or using setPTS \u003d 4 * PTS will make a video in 4x slower.

Ffmpeg -i input.mp4 -filter: v "setpts \u003d 0.125 * PTS" output.mp4

20. Speed \u200b\u200bup or slow down audio

To change the speed of the audio, use ATEMPO audio filter. This command will perform a double sound speed. For audio, you can use any value between 0.5 and 2.0.

Ffmpeg -i input.mkv -filter: a "atempo \u003d 2.0" -VN Output.mkv

To start working with FFMPEG, you should also check the official documentation on the FFMpeg.org website and learn about all the possible things you can do with FFMPEG.

fFMPEG is really a powerful video codec / decoder. It works on the command line, and not in graphic interface. The command line is the black window that you will find by clicking and typing CMD, then press ENTER. It is also called the "command line". After setting, you enter the FFMPEG commands in one of these windows to use it.

Here are the main steps to "establish" and use it:

Installation

fFMPEG is now "installed." The command line now recognizes the FFMPEG command and tries to run them.

Update ffmpeg.

To update FFMPEG, just return to the download page in step 1 and download the file. postal index. Unpack the files and copy them over the old files in the folder created in step 2.

Using FFMPEG.

Using FFMPEG requires you to open a command prompt window, and then enter FFMPEG specific commands. Here is a typical FFMPEG command:

Ffmpeg -i video.mp4 -VN -Ar 44100 -AC 1 -B: a 32k -f mp3 audio.mp3

This command consists of four parts:

  1. fFMPEG - This command reports CMD that we want to run FFMPEG commands. CMD first searches for ffmpeg.exe in one of the folders from step 6 in the Installation section. If it is found, he will try to execute the command.
  2. -i Video.mp4 is an input file. We will work on this file.
  3. -VN -AR 44100 -AC 1 -B: A 32K -f MP3 is "Arguments". These symbols are similar to mini teams that accurately determine what we want to do. In this case, it is said that you need to create an MP3 file from the input source.
    • -VN - Leave from the video stream
    • -Ar 44100 - determines the audio resolution in Hertz.
    • -AC 1 - audio channels, only 1. It effectively "make mono".
    • -B: A 32K - Audio bitrate, installed on 32 kbps.
    • -f MP3 - Forced MP3 transformation. Without this FFMPEG command, it is trying to interpret what you want, based on the extension you use in the output file name.
  4. audio.mp3 is an output file.

As you can guess, this short command makes the MP3 audio file from the MP4 file.

To execute this command if you have a MP4 file to try it on, follow these steps:

  1. Click windows key + R.
  2. Type CMD then enter.
  3. Change the path to the file you want to work on. Type CD. It should look something like CD C: \\ Users \\ Name \\ Desktop \\.
  4. Now enter the FFMPEG command named your input file. The team will work with some feedback. When it is done, CMD will be available for more teams.

This is the main way to use FFMPEG. Teams can be much more complicated, but this is just because the program has so much energy. Using The FFmpeg Documentation, you can find out all the commands and create very powerful scripts. After that, you can save these scripts to file.bat so that you just need to double-click the file, and not dial the entire team every time. For example, This Answer Contains A Script That Will Create Mp3 "S From All the MP4" S in a Folder. Then we will combine the FFMPEG power with CMD power, and this is a pleasant place when you need to make professional video / audio coding in mountain files.

- We delete the X264, LIBX264-DEV packages, and ffmpeg if they were installed:

$ sudo apt-get Purge FFMPEG X264 LIBX264-DEV LIBMP3LAME-DEV

- If there is a package auto-update in the system, prohibit update the FFMPEG package:
If file "/Etc/apt/apt.conf.d/50unattended-upgrades" There is something in the "Package-BlackList" section of the FFMPEG package, if there is no file, create it:

$ sudo echo -e "Unattended-Upgrade :: Package-Blacklist (N" FFMPEG "; N);" \u003e /etc/apt/apt.conf.d/50unattended-upgrades.

For assembly x264. Needless latest version yasm.. Check which version is installed:

$ YASM --Version YASM 1.2.0 Compiled on Nov 20 2013.

If the versions coincide, then the next step

$ apt-get remove yasm $ wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz $ tar XVFZ YASM-1.2.0.tar.gz $ CD YASM-1.2 . $0 ./configure --Prefix \u003d / USR / Local $ Make $ Sudo Make Install $ YASM --Version YASM 1.2.0 compiled on Nov 20 2013.

- We obtain dependent packages required for installation FFMPEG and X264:

$ Sudo apt-get update $ sudo apt-get install build-essential subversion texi2html libfaac-dev libfaad-dev libmp3lame-dev libtheora-dev quilt libsdl1.2-dev libogg-dev libvorbis-dev liba52-dev libdts-dev libimlib2-dev libraw1394-dev libdc1394-22-dev libtheora-dev libgsm1-dev libfaac-dev libfaad-dev git-core checkinstall yasm libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev NASM PYTHON-CHARDET GSTREAMER1.0-LIBAV GSTREAMER0.10-FFMPEG

If during the installation process, the GSTREAMER0.10-FFMPEG package is obtained

add a new repository and update indexes

Sudo Add-APT-Repository PPA: MC3MAN / TRUSTY-MEDIA Sudo Apt-Get Update

after that, repeat the process of installing packages

- Install x264 from source

$ mkdir ~ / src; CD ~ / src $ git clone git: //git.videolan.org/x264.git $ cd ./x264/ $ ./configure --Prefix \u003d / USR / Local --Enable-Shared $ Make $ Sudo Checkinstall - pkgname \u003d x264 --pkgversion head -c 7` "--Backup \u003d No --Deldoc \u003d YES --Fstrans \u003d No --Default Sudo Checkinstall --pkgname \u003d x264 --pkgVersion "2:0.`grep x264_build x264.h -m1 | Cut -d "" -F3`.`git Rev-List Head | WC -L` + Git `Git Rev-List Head -n 1 | Head -c 7`" --Backup \u003d No --Default $ sudo make install-lib-dev && sudo cp libx264.a / usr / local / lib / / USR / LOCAL / LIB /

- Install X264_B10 from source code

$ mkdir ~ / src; CD ~ / src $ git clone git: //git.videolan.org/x264.git $ cd ./x264/ $ ./configure --Prefix \u003d / USR / Local --enable-shared --bit-depth \u003d 10 $ make $ sudo checkinstall --pkgname \u003d x264_b10 --pkgversion "2: 0.`grep x264_build x264.h -m1 | Cut -d "" -F3`. `git Rev-List Head | WC -L` + Git`git Rev-List Head -n 1 | Head -c 7` "--Backup \u003d No --Deldoc \u003d YES --Fstrans \u003d No --Default $ Sudo Make Install-lib-dev $ Sudo CP LIBX264.A / USR / LOCAL / LIB /

Check which version of LAME is installed:

$ LAME -H LAME 64BITS VERSION 3.99.5 (http://lame.sf.net)

If you got an answer that the version is over 3.99, then we skip the next step

- sets support for the LAME codec

$ CD ~ / src $ sudo mkdir -p / usr / local / share / doc / lame $ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz $ tar xzvf lame-3.99.5.tar.gz $ CD LAME-3.99.5 $ ./configure --Enable-NASM --Disable-Shared $ Make $ Sudo Checkinstall --pkgname \u003d Lame-FFmpeg --pkgVersion \u003d "3.99 .5 "--Backup \u003d no --Default --Deldoc \u003d YES

- Install Libxvid from source

$ cd ~ / src $ wget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz $ tar xzvf xvidcore-1.3.3.tar.gz $ cd ./xvidcore/Build/GeneRic $ ./configure --Prefix \u003d / USR / Local $ Make $ Sudo Make Install Apt-Get Install Libopencore-AMRNB-DEV Libopencore-AMRWB-DEV LIBOPENCORE-DEV LIBFAAC-DEV LIBTHEORA-DEV LIBVORBIS-DEV LIBX264-DEV LIBDC1394-22- Dev Libxext-Dev LibxFixes-Dev

- Install FFMPEG with Codec support X264:

$ cd ~ / src $ git clone git: //git.videolan.org/ffmpeg.git $ cd ffmpeg / $ ./configure --prefix \u003d / usr / local --enable-GPL --Enable-PostProc --Enable -swscale --enable-pthreads --enable-x11grab - Libdc1394 - Libfaac - Libgmame - Libfaac - Libmp3Lame --Nable-libtheora - Libvorbis --Enable-libx264 --Enable -Libxvid --enable-nonfree --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb - meanable-shared $ make $ sudo checkinstall --pkgname \u003d ffmpeg --pkgversion \u003d "7: $ ( Date +% y% m% d% h% m) -git "--Backup \u003d no --Deldoc \u003d YES --Fstrans \u003d No --Default $ hash x264 FFMPEG FFplay FFProbe $ LDConfig -V

  • install the necessary coding utilities

$ sudo apt-get install mkvtooolnix gpac mencoder dvdrip avidemux

Check installation

$ Which FFMPEG / USR / LOCAL / BIN / FFMPEG

$ ffmpeg. -ENCODERS | grep. -E "mp3 | XVID | AAC | GSM | AMR | x264 | Theora | Vorbis"
FFmpeg Version N-55691-GCA7F637 Copyright 2000-2013 The FFmpeg Developers
Built On Aug 21 2013 15:44:17 WITH GCC 4.6 (Ubuntu / Linaro 4.6.3-1ubuntu5)
Configuration: --Prefix \u003d / USR / Local --Enable-GPL-Nonfree --enable-Shared - Nonfree - Libopencore-Amrnb - Libopencore-AmrWB - Libopencore-AmrWB - Libopencore-AmrWB - Libopencore-AmrWB - Libfaac - -Enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 - Libx264 - Libxvid
Libavutil 52. 42.100 / 52. 42.100
Libavcodec 55. 29.100 / 55. 29.100
LibavFormat 55. 14.100 / 55. 14.100
LIBAVDEVICE 55. 3.100 / 55. 3.100
LibavFilter 3. 82.100 / 3. 82.100
LIBSWSCALE 2. 5.100 / 2. 5.100
LIBSWRESAMPLE 0. 17.103 / 0. 17.103
LIBPOSTPROC 52. 3.100 / 52. 3.100
V ... Libx264 LIBX264 H.264 / AVC / MPEG-4 AVC / MPEG-4 Part 10 (Codec H264)
... LIBX264RGB LIBX264 H.264 / AVC / MPEG-4 AVC / MPEG-4 Part 10 RGB (Codec H264)
V ... Libxvid Libxvidcore MPEG-4 Part 2 (Codec MPEG4)
V ... Libtheora LiBtheora Theora (Codec Theora)
A ... X ... AAC AAC (Advanced Audio Coding)
A ... Libfaac Libfaac AAC (Advanced Aac Coding)
A ... Libopencore_amrnb Opencore AMR-NB (Adaptive Multi-Rate Narrow-Band) (Codec AMR_NB)
A ... LibgSm Libgsm GSM (Codec GSM)
A ... LibgSm_ms LibgSm GSM Microsoft Variant (Codec GSM_MS)
A ... LIBMP3LAME LIBMP3LAME MP3 (MPEG Audio Layer 3) (Codec mp3)
A ... x ... vorbis vorbis
A ... Libvorbis Libvorbis (Codec Vorbis)

Examples of using

Enclosure Coding:

Ffmpeg -i input. AVI -ACODEC LIBFAAC -AB 128K -AC 2 -VCodec Libx264 -VPRE Slow -Crf 22 -threads 0 Output. MP4

The lower parameter -Crf., the higher the quality, but more file. Reasonable are values \u200b\u200bfrom 18 to 28.

Two duct coding:

Ffmpeg -i input. AVI -PASS 1 -VCodec Libx264 -VPRE Fast_FirstPass -B 512K -BT 512K -Threads 0 -F RawVideo -an -Y / DeV / NULL && FFMPEG -I INPUT. AVI -PASS 2 -ACODEC LIBFAAC -AB 128K -AC 2 -VCodec Libx264 -VPRE Fast -B 512K -BT 512K -Threads 0 Output. MP4

Recoding for iPod (640 × 480):

Ffmpeg -i input. AVI -ACODEC LIBFAAC -AQ 100 -AC 2 -VCodec Libx264 -VPRE Slow -VPre iPod640 -Crf 26 -Map _meta_data 0: 0 -VF Scale \u003d 640: -1 -Threads 0 Output. MP4

1. Receive information about the video file

ffmpeg -i video.avi.

2. Turn a set of pictures in video

ffmpeg -f image2 -i image% d.jpg video.mpg This command converts all the pictures from the current directory (called image1.jpg, image2.jpg, etc.) in video file Video.Mpg (Translator Note: I like this format more: ffmpeg -r 12 -y -i "image_% 010d.png" Output.mpg. Here the Frame Rate (12) is set for the video, the format "image_% 010d.png" means that the pictures will be signed in the form of image_0000000001.png, image_0000000002.png, etc., that is, in PrintF format)

3. Cut the video on the pictures

ffmpeg -i video.mpg image% d.jpg

This command will create image1.jpg files, image2.jpg, etc., the same PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI formats are supported.

4. Convert video to iPod / iPhone format

ffmpeg -i source_video.avi input -codec AAC -ab 128KB -Vcodec MPEG4 -B 1200KB -MBD 2 -Flags + 4MV + TELL -AIC 2 -cmp 2 -Subcmp 2 -S 320x180 -title x Final_Video.mp4

Explanations:

  • Source: Source_Video.avi.
  • Audio codec: AAC
  • Audio bitrate: 128KB / S
  • Video codec: MPEG4
  • Video Bitrate: 1200KB / S

5. Convert video to PSP format

FFMPEG -I Source_Video.avi -B 300 -S 320x240 -Vcodec XVID -AB 32 -Ar 24000 -ACODEC AAC Final_Video.mp4

Explanations:

  • Source: Source_Video.avi.
  • Audio codec: AAC
  • Audio bitrate: 32KB / s
  • Video codec: XVID
  • Video Bitrate: 1200KB / S
  • Video Size: 320 per 180 pixels
  • VIDEO VIDEO: Final_Video.mp4

6. Extract the sound track from video and save to mp3

ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations:

  • Source: Source_Video.avi.
  • Bitrate Audio: 192KB / S
  • Output format: mp3
  • Received audio file: sound.mp3

7. Convert WAV to mp3

FFMPEG -I SON_ORIGINE.WAV -VN -AR 44100 -AC 2 -AB 192 -F MP3 SON_FINAL.MP3

8. Convert.avi V.mpg.

ffmpeg -i video_origine.avi video_finale.mpg 

9. Convert.mpg V.Avi.

ffmpeg -i video_origine.mpg video_finale.avi 

10. Convert.avi V.Gif (without compression)

ffmpeg -i video_enigine.avi gif_anime.gif

11. Add sound to video

ffmpeg -i syon.wav -i video_origine.avi video_finale.mpg

12. Convert.avi V.Flv

ffmpeg -i video_origine.avi -b 56 -ar 44100 -B 200 -R 15 -S 320x240 -F FLV video_finale.flv

13. Convert.avi V.DV

ffmpeg -i video_origine.avi -s PAL -R PAL -ASPECT 4: 3 -AR 48000 -AC 2 video_finale.dv

Ffmpeg -i video_origine.avi -target PAL-DV video_finale.dv

14. Convert.avi in \u200b\u200bMPEG for DVD players

FFMPEG -i Source_Video.avi -Target Pal-DVD -PPS 2000000000 -ASPECT 16: 9 FinalE_Video.mpeg

Explanations:

  • Output format: Pal-DVD
  • Maximum size for the output file: 2000000000 (2 GB)
  • Widescreen format: 16: 9

15. Compress .AVI in DivX

ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi

16. Squeeze Ogg Theora in MPEG DVD

ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpg2video -codec mp3 film_termin.mpg

17. Compress .AVI in SVCD MPEG2

ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg

PAL format:

Ffmpeg -i video_origine.avi -target PAL-SVCD video_finale.mpg

18. Compress .AVI in VCD MPEG2

NTSC format:

Ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg

PAL format:

Ffmpeg -i video_origine.avi -target PAL-VCD video_finale.mpg

19. Multidisciplinary coding with FFMPEG

FFMPEG -I Fichierenentree -Pass 2 -Passlogfile FFMPEG2PASS FichIersortie-2

20. Convert.m4b V.mp3

ffmpeg -i filename.m4b -acodec libmp3lame -ar 22050 filename.mp3 or find -iname "* .m4b" -Print0 | Xargs -0 -i () ffmpeg -i () -acodec libmp3lame -ar 22050 () .mp3

Update

We delete previously installed packages:

Sudo Apt-Get Remove FFmpeg X264 LIBX264-DEV

Upgrade x264.:

CD ~ / SRC / x 264 Make Distclean Git Pull

Upgrade Ffmpeg.:

CD ~ / SRC / FFmpeg make Distclean SVN Update

In both cases, repeat the installation procedure Ffmpeg. and x264.As previously described, only from the place "./configure la-la-la ..."

Cancel all changes made under this instruction

sudo apt-get remove x264 ffmpeg build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libmp3lame-dev libsdl1.2 -dev libtheora-dev libvorbis-dev libvpx-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev rm -RF ~ / src / x264 ~ / src / ffmpeg

Addition

if you need to install x264 to work with a video of 10 bits. Then yes. It is worth it all. Now about LIBX264 library. FFMPEG in Ubuntu works not with the X264 codec and directly with the library coding libx264.so.123 it is located in the directory with architecturally dependent libraries. First for the normal configuration x264 to work in a bundle with FFMPEG (obtaining a video stream video for encoding from FFMPEG) Before starting the X264 configuration, you must install the following packages: libavformat-dev, libffms2-dev, libgpac-dev, libswscale-dev. After installing these packages, performing. / Configure We will see the following:

/ scr / x264 $ ./configure

Platform: x86_64.
System: Linux
CLI: Yes
LIBX264: INTERNAL. internal LIBX264 coding library
Shared: No. - LIBX264.SO systemic biliothek. *** will not be collected. Namely, it uses FFMPEG for encoding and processing video.
Static: No.
ASM: Yes - Assembly optimized for the processor installed on the computer
Interlaced: Yes - Enabled work with ispro
AVS: No. - Support for working with Avisync on Linux it is not
LavF: Yes - Support for input files of all formats that ffmpeg understands
FFMS: Yes - Also included FFMPEG support that specifically - intense. It seems to support formats that FFMPEG can handle incorrect or something like that.
GPAC: Yes.
GPL: Yes
Thread: Posix.

Debug: No.
GProf: No.
Strip: No.
Pic: No.
Visualize: No.
Bit Depth: 8 coding in video files with color depth only 8 bits
Chroma Format: All

And so we see that our X264 will be collected with the support of everything that is possible, but the FFMPEG will not work. Now what needs to be done to ensure the work of FFMPEG directly with the Codec we assembled. To do this, you need to configure x264 with the following keys:

Prefix \u003d / usr - All compiled files will be located in the / usr directory
- bindir \u003d / usr / bin - Put the X264 codec in the / usr / bin software folder and not in the folder of the collected locally programs / USR / Local / Bin installed by default.
- libdir \u003d / usr / lib / x86_64-linux-gnu - Put library coding libx264.so. *** In the directory of architecturally dependent libraries (I draw your attention that I have 64 discharge system And accordingly, the Directory "x86_64-linux-gnu" is used for other architectures should also be used to other directory)
- Enable-Shared - Includes the creation of a dynamic library of coding libx264.so. *** which will look for FFMPEG when configured with the X264 codec support enabled (as far as I know it must be included in the configuration key and there who knows it I have not tried to compile FFMPEG it is possible for ffmpeg ligament C libx264.so. *** You have to include some other configuration keys)
- Enable-Static - Includes Creating Static Libx264.So Libraries (FFMPEG Note works with a dynamic and not static library. The dynamic library in the file name at the end is also the version number. That is why after installation new version Codec X264 to ensure work with it FFMPEG it (FFMPEG) every time you have to reassemble Pona.
- bit-depth \u003d 10 - The codec configuration is turned on to build only 10 bit video (including libraries. The playback will be both 8-bit video and 10-bit, but it will be created by this codec only 10 bit video. If this option is not needed - then Do not put it and the codec will be collected, which will create only 8-bit video.

Here is what we get when the Codec Codec configuration is configured:

/ SCR / X264 $ ./configure --Prefix \u003d / USR --Bindir \u003d / usr / bin --libdir \u003d / usr / lib / x86_64-linux-gnu --enable-shared --enable-static --bit- depth \u003d 10.
Fatal: not a git repository (Or Any of the Parent Directories): .git
Platform: x86_64.
System: Linux
CLI: Yes - work on the command line
LIBX264: INTERNAL. - Creating internal libraries
Shared: Yes. - Creating dynamic libraries
Static: Yes - Creating static libraries
ASM: Yes - optimization for the processor (before assembly you need to install YASM
Interlaced: Yes - work with faster video
AVS: No. - Avisync BEAUTION
LavF: Yes - FFMPEG formats support
FFMS: Yes - Support for other formats
GPAC: Yes - Optimization of work with OpenSourse Multimedia
GPL: Yes
Thread: Posix.
Filters: Resize Crop Select_Every
Debug: No.
GProf: No.
Strip: No.
Pic: Yes
Visualize: No.
Bit Depth: 10 - Creating Toklko 10 Bit Video (High10 coding profiles, High422 and High444
Chroma Format: All

For more information on the X264 codec configuration keys, you can view the X264 command in the source code directory. / Configure -h

in principle, here is its maintenance:

/ scr / x264 $ ./configure -h
Usage: ./configure.
Help:
- H, --Help Print This Message
Standard Options:
- Prefix \u003d Prefix Install Architecture-Independent Files in Prefix
- Exec-Prefix \u003d EPrefix Install Architecture-Dependent Files in EPrefix
- Bindir \u003d Dir Install BINARIES IN DIR
- libdir \u003d Dir Install LIBS IN DIR
- Includedir \u003d Dir Install Includes in Dir
- Extra-AsFlags \u003d Easflags Add Easflags to AsFlags
- Extra-CFlags \u003d Ecflags Add Ecflags to CFlags
- Extra-LDFlags \u003d Eldflags Add Eldflags to LDFlags
Configuration Options:
- Disable-Cli Disable CLI
- System-Libx264 Use System Libx264 Instead of Internal
- ENABLE-SHARED BUILD SHARED LIBRARY
- ENABLE-STATIC BUILD STATIC Library
- Disable-GPL DISABLE GPL-Only Features
- Disable-Thread Disable MultithReaded Encoding
- Enable-Win32thread Use Win32Threads (Windows Only)
- DISABLE-INTERLACED DISABLE INTERLACED ENCODING SUPPORT
- Enable-visualize Enable Visualization (X11 Only)
- Bit-Depth \u003d Bit_Depth Set Output Bit Depth (8-10)
- Chroma-Format \u003d Format Output Chroma Format (420, 422, 444, All)
Advanced Options:
- Disable-ASM Disable Platform-Specific Assembly Optimizations
- Enable-Debug Add -g
- Enable-GProf Add -PG
- Enable-Strip Add -s
- Enable-Pic Build Position-Independent Code
Cross-Compilation:
- HOST \u003d Host Build Programs to Run on Host
- Cross-Prefix \u003d Prefix Use Prefix for Compulation Tools
- Sysroot \u003d Sysroot Root of Cross-Build Tree
External Library Support:
- Disable-Avs Disable Avisynth Support (Windows Only)
- Disable-Swscale Disable Swscal Support
- Disable-Lavf Disable LibavFormat Support
- Disable-FFMS Disable Ffmpegsource Support
- Disable-GPAC Disable GPAC Support

This is a program (a set of media libraries with an executable file), giving unlimited power over the video and allowing you to save a bunch of time.

Description

Not once anyone came across the situation when it was necessary:

  • cut the video on the part or on the contrary, glue from two;
  • cut the sound from the clip, replace sound track in the film (throw out the bubble, insert the original);
  • impose subtitles;
  • crop by frame (CROP);
  • convert for iPhone / PSP / School;
  • and so on like.

And every time you can argue, the search began, where to steal what software to do it. So, all this knows how to make FFMPEG, which is not worth a penny (although it is desirable to throw a few help to boys).

And some of the rather well-known video editors are essentially a graphic superstructure over FFMPEG, so that. But no one says that it is bad, for example, XVID4PSP is a wonderful converter. Just why use a heavy GUI, when all the same can be made gracefully and quickly.

Some video operations are performed without recoding (-vcodec Copy -ACODEC COPY), some require recoding (not fit into parts, it can be installed in such cases option -CRF 18).

Receiving information on the file

The most basic team will be needed as preceding for many others.

It is very simple:

fFProbe.exe. 1 .mp4

The result will be approximately the following:

Among the heaps of information you can find that the video goes two minutes (Duration: 00: 02: 00.07) and in the container two tracks:

  1. Stream # 0: 0 (UND): Video: H264 (High) (AVC1 / 0x31637661), YUV420P, 1280x720, 1389 KB / S, 29.97 FPS
  2. Stream # 0: 1 (UND): Audio: AAC (MP4A / 0x6134706D), 44100 Hz, Stereo, Fltp, 192 KB / S

Cut fragment video

This command will cut out from the 1.mp4 file from 00:03:05 video cluster 66 seconds (00:01:06) and save it to the file under the name Cut.mp4.

Cut a fragment video from the source code with multiple audio tracks

We look at the file information:

fFProbe.exe. 1 .mp4

In addition to other information, we see, for example, this:

Duration: 01: 52: 52.80, Start: 0.000000, Bitrate: 2768 KB / S Stream # 0: 0: Video: Mpeg4 (XVID / 0x44495658), YUV420P, 704x384 Stream # 0: 1: Audio: AC3 (/ 0x2000), 48000 Hz, 5.1 (Side), S16, 448 KB / S Stream # 0: 2: Audio: AC3 (/ 0x2000), 48000 Hz, 5.1 (Side), S16, 448 KB / S

ffmpeg -i 1 .avi -map 0: 0 -map 0: 2 -SS 01:37: 34 -T 63 -Vcodec Copy -ACodec Copy Cut.avi

There is a nuance. If the track in AC3, Codecid is broken down (there was such a joint of the AVI container, but perhaps it was corrected), and there will be no sound. However, you can add everything in MKV:

ffmpeg -fflags genpts -i 1 .avi -map 0: 0 -map 0: 2 -SS 01:37: 34 -T 63 -Vcodec Copy -ACodec Copy Cut.mkv

Cut subtitles from container

First, look at the file information (as in the example above), we define the track number and:

fFmpeg -i 1 .mkv -map 0: 2 1 .Ass

This is suitable for extracting audio tracks. Well, the video too. In short, in general for any flow from the container. Naturally, the output file extension must be set according to the stream.

Put on every frame Watermark

For example, you recorded lettules, but your nickname falls in the corner of the screen and it is necessary to close it with a black rectangle. Or another situation: I want to go to the corner of some kind of logo in the corner.

This is done like this:

ffmpeg.exe. -i 1 .mp4 -vf "Movie \u003d logo.png; Overlay \u003d 16: 16" -CRF 18 2 .mkv

It is necessary to transcoding, therefore it is necessary to specify the encoding parameters, which performs the -CRF 18 option. Watermark lies in the same directory under the name logo.png. Parameter 16:16 - Coordinates of the positioning of the upper left corner of the Watermark.

Video coding

Basically, in order to reduce the file size. For example, video from digital or captured FRAPS video.

I saw the teams for several lines, where bitrates, quantifiers, garfbots and other hardcore were signed, but I don't understand anything in this, I would like something easier. And it is it, it's easier to now:

ffmpeg.exe. -i 1 .avi -Crf 18 out.mp4

The CRF parameter is a certain level of quality and takes values \u200b\u200bfrom 0 to 51, where:

  • 0 - the best quality;
  • 51 - worst quality. If you choose more than 51, for example 54 or 9000 - it will be taken anyway 51.