diff --git a/index.html b/index.html index 8d56d6a..9920029 100644 --- a/index.html +++ b/index.html @@ -42,7 +42,9 @@

What do you want to do?

-

Click one of the following categories to see possible commands of that type:

+

Click one of the following categories to see commands of that type:

+ + @@ -50,7 +52,8 @@ - + + @@ -61,6 +64,75 @@
+
+

Learn about FFmpeg basics

+ + + + + + +
+
+

Learn about more advanced FFmpeg concepts

+ + + + + + +

Change container (rewrap)

@@ -79,13 +151,13 @@
-i input_file.ext
path and name of the input file
-c copy
copy the streams directly, without re-encoding.
-map 0
map all streams of the input to the output.
- By default, ffmpeg will only map one stream of each type (video, audio, subtitles) to the output file. However, files may have multiple streams of a given type - for example, a video may have several audio tracks for different languages. Therefore, if you want to preserve all the streams in the original, it's necessary to use this option.
+ By default, FFmpeg will only map one stream of each type (video, audio, subtitles) to the output file. However, files may have multiple streams of a given type - for example, a video may have several audio tracks for different languages. Therefore, if you want to preserve all the streams in the original, it's necessary to use this option.
output_file.ext
path and name of the output file.
The new container you are rewrapping to is defined by the filename extension used here, e.g. .mkv, .mp4, .mov.

Important caveat

It may not be possible to rewrap a file's contents to a new container without re-encoding one or more of the streams within (that is, the video, audio, and subtitle tracks). Some containers can only contain streams of a certain encoding type: for example, the .mp4 container does not support uncompressed audio tracks. (In practice .mp4 goes hand-in-hand with a H.264-encoded video stream and an AAC-encoded video stream, although other types of video and audio streams are possible). Another example is that the Matroska container does not allow data tracks; see the MKV to MP4 recipe.

-

In such cases, ffmpeg will throw an error. If you encounter errors of this kind, you may wish to consult the list of transcoding recipes.

+

In such cases, FFmpeg will throw an error. If you encounter errors of this kind, you may wish to consult the list of transcoding recipes.

@@ -136,7 +208,7 @@
ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-
-c:v prores
Tells ffmpeg to transcode the video stream into Apple ProRes 422
+
-c:v prores
tells FFmpeg to transcode the video stream into Apple ProRes 422
-profile:v 1
Declares profile of ProRes you want to use. The profiles are explained below:
-vf yadif
Runs a deinterlacing video filter (yet another deinterlacing filter) on the new file. -vf is an alias for -filter:v.
-
-c:a pcm_s16le
Tells ffmpeg to encode the audio stream in 16-bit linear PCM
+
-c:a pcm_s16le
tells FFmpeg to encode the audio stream in 16-bit linear PCM
output_file
path, name and extension of the output file
The extension for the QuickTime container is .mov.
@@ -173,20 +245,20 @@
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
+
-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 copy
tells FFmpeg to copy the audio stream without re-encoding it
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

-
-preset veryslow
This option tells ffmpeg to use the slowest preset possible for the best compression quality.
+
-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.
-crf 18
Specifying a lower CRF will make a larger file with better visual quality. For H.264 files being encoded with a 4:2:0 chroma subsampling scheme (i.e., using -pix_fmt yuv420p), the scale ranges between 0-51, with 0 being lossless and 51 the worst possible quality.
If no crf is specified, libx264 will use a default value of 23. 18 is often considered a “visually lossless” compression.
-

For more information, see the FFmpeg and H.264 Encoding Guide on the ffmpeg wiki.

+

For more information, see the FFmpeg and H.264 Encoding Guide on the FFmpeg wiki.

@@ -234,11 +306,11 @@

Create FFV1 Version 3 video in a Matroska container with framemd5 of input

ffmpeg -i input_file -map 0 -dn -c:v ffv1 -level 3 -g 1 -slicecrc 1 -slices 16 -c:a copy output_file.mkv -f framemd5 -an framemd5_output_file

-

This will losslessly transcode your video with the FFV1 Version 3 codec in a Matroska container. In order to verify losslessness, a framemd5 of the source video is also generated. For more information on FFV1 encoding, try the ffmpeg wiki.

+

This will losslessly transcode your video with the FFV1 Version 3 codec in a Matroska container. In order to verify losslessness, a framemd5 of the source video is also generated. For more information on FFV1 encoding, try the FFmpeg wiki.

ffmpeg
starts the command.
-i input_file
path, name and extension of the input file.
-
-map 0
Map all streams that are present in the input file. This is important as ffmpeg will map only one stream of each type (video, audio, subtitles) by default to the output video.
+
-map 0
Map all streams that are present in the input file. This is important as FFmpeg will map only one stream of each type (video, audio, subtitles) by default to the output video.
-dn
ignore data streams (data no). The Matroska container does not allow data tracks.
-c:v ffv1
specifies the FFV1 video codec.
-level 3
specifies Version 3 of the FFV1 codec.
@@ -258,32 +330,6 @@
- - - - - + + + + + + @@ -630,11 +707,11 @@

Join files together

ffmpeg -f concat -i mylist.txt -c copy output_file

-

This command takes two or more files of the same file type and joins them together to make a single file. All that the program needs is a text file with a list specifying the files that should be joined. However, it only works properly if the files to be combined have the exact same codec and technical specifications. Be careful, ffmpeg may appear to have successfully joined two video files with different codecs, but may only bring over the audio from the second file or have other weird behaviors. Don’t use this command for joining files with different codecs and technical specs and always preview your resulting video file!

+

This command takes two or more files of the same file type and joins them together to make a single file. All that the program needs is a text file with a list specifying the files that should be joined. However, it only works properly if the files to be combined have the exact same codec and technical specifications. Be careful, FFmpeg may appear to have successfully joined two video files with different codecs, but may only bring over the audio from the second file or have other weird behaviors. Don’t use this command for joining files with different codecs and technical specs and always preview your resulting video file!

ffmpeg
starts the command
-f concat
forces ffmpeg to concatenate the files and to keep the same file format
-
-i mylist.txt
path, name and extension of the input file. Per the ffmpeg documentation, it is preferable to specify relative rather than absolute file paths, as allowing absolute file paths may pose a security risk.
+
-i mylist.txt
path, name and extension of the input file. Per the FFmpeg documentation, it is preferable to specify relative rather than absolute file paths, as allowing absolute file paths may pose a security risk.
This text file contains the list of files to be concatenated and should be formatted as follows:
file './first_file.ext'
 file './second_file.ext'
@@ -646,7 +723,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file-c copy
use stream copy mode to re-mux instead of re-encode
output_file
path, name and extension of the output file
-

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

+

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

@@ -666,14 +743,14 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_fileffmpeg
Starts the command.
-i input_file
Takes in a normal file.
-c copy
Use stream copy mode to re-mux instead of re-encode.
-
-map 0
Tells ffmpeg to map all streams of the input to the output.
-
-f segment
Use segment muxer for generating the output.
+
-map 0
tells FFmpeg to map all streams of the input to the output.
+
-f segment
Use segment muxer for generating the output.
-segment_time 60
Set duration of each segment (in seconds). This example creates segments with max. duration of 60s each.
-reset_timestamps 1
Reset timestamps of each segment to 0. Meant to ease the playback of the generated segments.
output_file-%03d.mkv

Path, name and extension of the output file.
- In order to have an incrementing number in each segment filename, FFmpeg supports printf-style syntax for a counter.

+ In order to have an incrementing number in each segment filename, FFmpeg supports printf-style syntax for a counter.

In this example, '%03d' means: 3-digits, zero-padded
Examples:

    @@ -705,8 +782,8 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file-ss 00:02:00
    sets in point at 00:02:00
    -to 00:55:00
    sets out point at 00:55:00
    -c copy
    use stream copy mode (no re-encoding)
    -
    -map 0
    Tells ffmpeg to map all streams of the input to the output.
    - Note: watch out when using -ss with -c copy if the source is encoded with an interframe codec (e.g., H.264). Since ffmpeg must split on i-frames, it will seek to the nearest i-frame to begin the stream copy.
+
-map 0
tells FFmpeg to map all streams of the input to the output.
+ Note: watch out when using -ss with -c copy if the source is encoded with an interframe codec (e.g., H.264). Since FFmpeg must split on i-frames, it will seek to the nearest i-frame to begin the stream copy.
output_file
path, name and extension of the output file

Variation: trim video by setting duration, by using -t instead of -to

@@ -734,9 +811,9 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-
-t 5
Tells ffmpeg to stop copying from the input file after a certain time, and specifies the number of seconds after which to stop copying. In this case, 5 seconds is specified.
+
-t 5
tells FFmpeg to stop copying from the input file after a certain time, and specifies the number of seconds after which to stop copying. In this case, 5 seconds is specified.
-c copy
use stream copy mode to re-mux instead of re-encode
-
-map 0
Tells ffmpeg to map all streams of the input to the output.
+
-map 0
tells FFmpeg to map all streams of the input to the output.
output_file
path, name and extension of the output file
@@ -758,9 +835,9 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-
-ss 5
Tells ffmpeg what timecode in the file to look for to start copying, and specifies the number of seconds into the video that ffmpeg should start copying. To be more specific, you can use timecode such as 00:00:05.
+
-ss 5
tells FFmpeg what timecode in the file to look for to start copying, and specifies the number of seconds into the video that FFmpeg should start copying. To be more specific, you can use timecode such as 00:00:05.
-c copy
use stream copy mode to re-mux instead of re-encode
-
-map 0
Tells ffmpeg to map all streams of the input to the output.
+
-map 0
tells FFmpeg to map all streams of the input to the output.
output_file
path, name and extension of the output file
@@ -781,10 +858,10 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_fileThis command copies a video file starting from a specified time before the end of the file, removing everything before from the output. This can be used to create an excerpt, or extract content from the end of a video file (e.g. for extracting the closing credits).

ffmpeg
starts the command
-
-sseof -5
This parameter must stay before the input file. It tells ffmpeg what timecode in the file to look for to start copying, and specifies the number of seconds from the end of the video that ffmpeg should start copying. The end of the file has index 0 and the minus sign is needed to reference earlier portions. To be more specific, you can use timecode such as -00:00:05. Note that in most file formats it is not possible to seek exactly, so ffmpeg will seek to the closest point before.
+
-sseof -5
This parameter must stay before the input file. It tells FFmpeg what timecode in the file to look for to start copying, and specifies the number of seconds from the end of the video that FFmpeg should start copying. The end of the file has index 0 and the minus sign is needed to reference earlier portions. To be more specific, you can use timecode such as -00:00:05. Note that in most file formats it is not possible to seek exactly, so FFmpeg will seek to the closest point before.
-i input_file
path, name and extension of the input file
-c copy
use stream copy mode to re-mux instead of re-encode
-
-map 0
Tells ffmpeg to map all streams of the input to the output.
+
-map 0
tells FFmpeg to map all streams of the input to the output.
output_file
path, name and extension of the output file
@@ -807,8 +884,8 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_fileUpscaled, Pillar-boxed HD H.264 Access Files from SD NTSC source

ffmpeg -i input_file -c:v libx264 -filter:v "yadif, scale=1440:1080:flags=lanczos, pad=1920:1080:(ow-iw)/2:(oh-ih)/2, format=yuv420p" output_file

-
ffmpeg
Calls the program ffmpeg
-
-i
for input video file and audio file
+
ffmpeg
starts the command
+
-i input_file
path, name and extension of the input file
-c:v libx264
encodes video stream with libx264 (h264)
"
quotation mark to start filtergraph
yadif
deinterlacing filter (‘yet another deinterlacing filter’)
@@ -839,7 +916,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
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
+
-c:v libx264
tells FFmpeg to encode the video stream as H.264
-vf
video filtering will be used (-vf is an alias of -filter:v)
"
start of filtergraph (see below)
yadif
deinterlacing filter (‘yet another deinterlacing filter’)
@@ -850,9 +927,9 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file"
end of filtergraph
output file
path, name and extension of the output file
-

"yadif,format=yuv420p" is an ffmpeg filtergraph. Here the filtergraph is made up of one filter chain, which is itself made up of the two filters (separated by the comma).
+

"yadif,format=yuv420p" is an FFmpeg filtergraph. Here the filtergraph is made up of one filter chain, which is itself made up of the two filters (separated by the comma).
The enclosing quote marks are necessary when you use spaces within the filtergraph, e.g. -vf "yadif, format=yuv420p", and are included above as an example of good practice.

-

Note: ffmpeg includes several deinterlacers apart from yadif: bwdif, w3fdif, kerndeint, and nnedi.

+

Note: FFmpeg includes several deinterlacers apart from yadif: bwdif, w3fdif, kerndeint, and nnedi.

For more H.264 encoding options, see the latter section of the encode H.264 command.

Example

@@ -882,11 +959,11 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file-c:v libx264
encode video as H.264
-vf "fieldmatch,yadif,decimate"
applies these three video filters to the input video.
Fieldmatch is a field matching filter for inverse telecine - it reconstructs the progressive frames from a telecined stream.
- Yadif (‘yet another deinterlacing filter’) deinterlaces the video. (Note that ffmpeg also includes several other deinterlacers).
+ Yadif (‘yet another deinterlacing filter’) deinterlaces the video. (Note that FFmpeg also includes several other deinterlacers).
Decimate deletes duplicated frames.
output file
path, name and extension of the output file
-

"fieldmatch,yadif,decimate" is an ffmpeg filtergraph. Here the filtergraph is made up of one filter chain, which is itself made up of the three filters (separated by commas).
+

"fieldmatch,yadif,decimate" is an FFmpeg filtergraph. Here the filtergraph is made up of one filter chain, which is itself made up of the three filters (separated by commas).
The enclosing quote marks are necessary when you use spaces within the filtergraph, e.g. -vf "fieldmatch, yadif, decimate", and are included above as an example of good practice.

Note that if applying an inverse telecine procedure to a 29.97i file, the output framerate will actually be 23.976fps.

This command can also be used to restore other framerates.

@@ -997,7 +1074,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file:
divides between options of the same filter
reset=1
tells the filter to calculate the stats on every frame (increasing this number would calculate stats for groups of frames)
,
comma divides one filter in the chain from another
-
adrawgraph=lavfi.astats.Overall.Peak_level:max=0:min=-30.0
draws a graph using the overall peak volume calculated by the astats filter. It sets the max for the graph to 0 (dB) and the minimum to -30 (dB). For more options on data points that can be graphed see the ffmpeg astats documentation
+
adrawgraph=lavfi.astats.Overall.Peak_level:max=0:min=-30.0
draws a graph using the overall peak volume calculated by the astats filter. It sets the max for the graph to 0 (dB) and the minimum to -30 (dB). For more options on data points that can be graphed see the FFmpeg astats documentation
size=700x256:bg=Black
sets the background color and size of the output
[out]
ends the filterchain and sets the output
"
quotation mark to end the lavfi filtergraph
@@ -1081,7 +1158,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
ffmpeg
starts the command
-i input01 -i input02
Designates the files to use for inputs one and two respectively
-
-filter_complex
Lets ffmpeg know we will be using a complex filter (this must be used for multiple inputs)
+
-filter_complex
Lets FFmpeg know we will be using a complex filter (this must be used for multiple inputs)
"
quotation mark to start filtergraph
[0:v:0]tblend=all_mode=difference128[a]
Applies the tblend filter (with the settings all_mode and difference128) to the first video stream from the first input and assigns the result to the output [a]
[1:v:0]tblend=all_mode=difference128[b]
Applies the tblend filter (with the settings all_mode and difference128) to the first video stream from the second input and assigns the result to the output [b]
@@ -1090,7 +1167,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file-map [out]
Maps the output of the filter chain
-f nut
Sets the format for the output video stream to Nut
-c:v rawvideo
Sets the video codec of the output video stream to raw video
-
-
Tells ffmpeg that the output will be piped to a new command (as opposed to a file)
+
-
tells FFmpeg that the output will be piped to a new command (as opposed to a file)
|
Tells the system you will be piping the output of the previous command into a new command
ffplay -
Starts ffplay and tells it to use the pipe from the previous command as its input
@@ -1118,7 +1195,6 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_filePull specs from video file

ffprobe -i input_file -show_format -show_streams -show_data -print_format xml

This command extracts technical metadata from a video file and displays it in xml.

-

ffmpeg documentation on ffprobe (full list of flags, commands, www.ffmpeg.org/ffprobe.html)

ffprobe
starts the command
-i input_file
path, name and extension of the input file
@@ -1127,6 +1203,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file-show_data
adds a short “hexdump” to show_streams command output
-print_format
Set the output printing format (in this example “xml”; other formats include “json” and “flat”)
+

See also the FFmpeg documentation on ffprobe for a full list of flags, commands, and options.

@@ -1159,45 +1236,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
-

Generate image files from a video

- - - - - +

Generate image files from a video

@@ -1245,6 +1284,74 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file +
+
+

Create an animated GIF

+ + + + + + + + + + +

Create a video from images

@@ -1347,7 +1454,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_fileffmpeg
starts the command
-i input_video_file
path, name and extension of the input video file
-i input_image_file
path, name and extension of the image file
-
-filter_complex overlay=main_w-overlay_w-5:5
This calls the overlay filter and sets x and y coordinates for the position of the watermark on the video. Instead of hardcoding specific x and y coordinates, main_w-overlay_w-5:5 uses relative coordinates to place the watermark in the upper right hand corner, based on the width of your input files. Please see the ffmpeg documentation for more examples.
+
-filter_complex overlay=main_w-overlay_w-5:5
This calls the overlay filter and sets x and y coordinates for the position of the watermark on the video. Instead of hardcoding specific x and y coordinates, main_w-overlay_w-5:5 uses relative coordinates to place the watermark in the upper right hand corner, based on the width of your input files. Please see the FFmpeg documentation for more examples.
output_file
path, name and extension of the output file
@@ -1426,7 +1533,7 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_fileCalculate Loudness Levels

ffmpeg -i input_file -af loudnorm=print_format=json -f null -

This filter calculates and outputs loudness information in json about an input file (labeled input) as well as what the levels would be if loudnorm were applied in its one pass mode (labeled output). The values generated can be used as inputs for a 'second pass' of the loudnorm filter allowing more accurate loudness normalization than if it is used in a single pass.

-

These instructions use the loudnorm defaults, which align well with PBS recommendations for target loudness. More information can be found at the loudnorm documentation.

+

These instructions use the loudnorm defaults, which align well with PBS recommendations for target loudness. More information can be found at the loudnorm documentation.

Information about PBS loudness standards can be found in the PBS Technical Operating Specifications document. Information about EBU loudness standards can be found in the EBU R 128 recommendation document.

ffmpeg
starts the command
@@ -1530,14 +1637,14 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file