diff --git a/index.html b/index.html index 6710247..849e0fc 100644 --- a/index.html +++ b/index.html @@ -250,18 +250,19 @@

Transcode to H.264

-

ffmpeg -i input_file -c:v libx264 -pix_fmt yuv420p -c:a copy output_file

+

ffmpeg -i input_file -c:v libx264 -pix_fmt yuv420p -c:a aac output_file

This command takes an input file and transcodes it to H.264 with an .mp4 wrapper, keeping the audio the same codec as the original. The libx264 codec defaults to a “medium” preset for compression quality and a CRF of 23. CRF stands for constant rate factor and determines the quality and file size of the resulting H.264 video. A low CRF means high quality and large file size; a high CRF means the opposite.

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-c:v libx264
tells FFmpeg to encode the video stream as H.264
-pix_fmt yuv420p
libx264 will use a chroma subsampling scheme that is the closest match to that of the input. This can result in Y′CBCR 4:2:0, 4:2:2, or 4:4:4 chroma subsampling. QuickTime and most other non-FFmpeg based players can’t decode H.264 files that are not 4:2:0. In order to allow the video to play in all players, you can specify 4:2:0 chroma subsampling.
-
-c:a copy
tells FFmpeg to copy the audio stream without re-encoding it
+
-c:a aac
encode audio as AAC.
+ AAC is the codec most often used for audio streams within an .mp4 container.
output_file
path, name and extension of the output file

In order to use the same basic command to make a higher quality file, you can add some of these presets:

-

ffmpeg -i input_file -c:v libx264 -pix_fmt yuv420p -preset veryslow -crf 18 -c:a copy output_file

+

ffmpeg -i input_file -c:v libx264 -pix_fmt yuv420p -preset veryslow -crf 18 -c:a aac output_file

-preset veryslow
This option tells FFmpeg to use the slowest preset possible for the best compression quality.
Available presets, from slowest to fastest, are: veryslow, slower, slow, medium, fast, faster, veryfast, superfast, ultrafast.
@@ -332,7 +333,7 @@

Convert DVD to H.264

-

ffmpeg -i concat:input_file1\|input_file2\|input_file3 -c:v libx264 -c:a copy output_file.mp4

+

ffmpeg -i concat:input_file1\|input_file2\|input_file3 -c:v libx264 -c:a aac output_file.mp4

This command allows you to create an H.264 file from a DVD source that is not copy-protected.

Before encoding, you’ll need to establish which of the .VOB files on the DVD or .iso contain the content that you wish to encode. Inside the VIDEO_TS directory, you will see a series of files with names like VTS_01_0.VOB, VTS_01_1.VOB, etc. Some of the .VOB files will contain menus, special features, etc, so locate the ones that contain target content by playing them back in VLC.

@@ -341,17 +342,18 @@ -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB
The backslash is simply an escape character for the pipe (|).
-c:v libx264
sets the video codec as H.264
-
-c:a copy
audio remains as-is (no re-encode)
+
-c:a aac
encode audio as AAC.
+ AAC is the codec most often used for audio streams within an .mp4 container.
output_file.mp4
path and name of the output file

It’s also possible to adjust the quality of your output by setting the -crf and -preset values:

-

ffmpeg -i concat:input_file1\|input_file2\|input_file3 -c:v libx264 -crf 18 -preset veryslow -c:a copy output_file.mp4

+

ffmpeg -i concat:input_file1\|input_file2\|input_file3 -c:v libx264 -crf 18 -preset veryslow -c:a aac output_file.mp4

-crf 18
sets the constant rate factor to a visually lossless value. Libx264 defaults to a crf of 23, considered medium quality; a smaller CRF value produces a larger and higher quality video.
-preset veryslow
A slower preset will result in better compression and therefore a higher-quality file. The default is medium; slower presets are slow, slower, and veryslow.

Bear in mind that by default, libx264 will only encode a single video stream and a single audio stream, picking the ‘best’ of the options available. To preserve all video and audio streams, add -map parameters:

-

ffmpeg -i concat:input_file1\|input_file2 -map 0:v -map 0:a -c:v libx264 -c:a copy output_file.mp4

+

ffmpeg -i concat:input_file1\|input_file2 -map 0:v -map 0:a -c:v libx264 -c:a aac output_file.mp4

-map 0:v
encodes all video streams
-map 0:a
encodes all audio streams
@@ -880,8 +882,8 @@

Join, trim, or excerpt a video

- - + +

Join files together

@@ -905,7 +907,53 @@

For more information, see the FFmpeg wiki page on concatenating files.

- + + + + + +
+

Join files together

+

ffmpeg -i input1.avi -i input2.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[videoOut][audioOut]" -map "[videoOut]" -map "[audioOut]" output_file

+

This command takes two or more files of the different file types and joins them together to make a single file.

+

However, it only works properly if the files to be combined have the same dimensions (e.g., 720x576).

+

Some aspects of the input files will be normalised: for example, if an input file contains a video track and an audio track that do not have exactly the same duration, the shorter one will be padded. In the case of a shorter video track, the last frame will be repeated in order to cover the missing video; in the case of a shorter audio track, the audio stream will be padded with silence.

+

Note that if the input files have different framerates, the output file will be of variable framerate.

+
+
ffmpeg
starts the command
+
-i input1.ext
path, name and extension of the first input file
+
-i input2.ext
path, name and extension of the second input file
+
-filter_complex
states that a complex filtergraph will be used
+
"
quotation mark to start filtergraph
+
[0:v:0][0:a:0]
selects the first video stream and first audio stream from the first input.
+ Each reference to a specific stream is enclosed in square brackets. In the first stream reference, 0:v:0, the first zero refers to the first input file, v means video stream, and the second zero indicates that it is the first video stream in the file that should be selected. Likewise, 0:a:0 means the first audio stream in the first input file.
+ As demonstrated above, ffmpeg uses zero-indexing: 0 means the first input/stream/etc, 1 means the second input/stream/etc, and 4 would mean the fifth input/stream/etc.
+
[1:v:0][1:a:0]
As described above, this means select the first video and audio streams from the second input file.
+
concat=
starts the concat filter
+
n=2
states that there are two input files
+
:
separator
+
v=1
sets the number of output video streams.
+ Note that this must be equal to the number of video streams selected from each segment.
+
:
separator
+
a=1
sets the number of output audio streams.
+ Note that this must be equal to the number of audio streams selected from each segment.
+
[videoOut]
name of the concatenated output video stream. This is a variable name which you define, so you could call it something different, like “vOut”, “outv”, or “banana”.
+
[audioOut]
name of the concatenated output audio stream. Again, this is a variable name which you define.
+
"
quotation mark to end filtergraph
+
-map "[videoOut]"
map the concatenated video stream into the output file by referencing the variable defined above
+
-map "[audioOut]"
map the concatenated audio stream into the output file by referencing the variable defined above
+
output_file
path, name and extension of the output file
+
+

If no characteristics of the output files are specified, ffmpeg will use the default encodings associated with the given output file type. To specify the characteristics of the output stream(s), add flags after each -map "[out]" part of the command.

+

For example, to ensure that the video stream of the output file is visually lossless H.264 with a 4:2:0 chroma subsampling scheme, the command above could be amended to include the following:
+ -map "[videoOut]" -c:v libx264 -pix_fmt yuv420p -preset veryslow -crf 18

+

Likewise, to encode the output audio stream as mp3, the command could include the following:
+ -map "[audioOut]" -c:a libmp3lame -dither_method modified_e_weighted -qscale:a 2

+

For more information, see the FFmpeg wiki page on concatenating files of different types.

+ +
+ + @@ -1036,6 +1084,7 @@
ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-c:v libx264
encodes video stream with libx264 (h264)
+
-filter:v
a video filter will be used
"
quotation mark to start filtergraph
yadif
deinterlacing filter (‘yet another deinterlacing filter’)
By default, yadif will output one frame for each frame. Outputting one frame for each field (thereby doubling the frame rate) with yadif=1 may produce visually better results.