From c0e9a05e1d40b3dfe5e3eb1d33b79d1508d22e94 Mon Sep 17 00:00:00 2001 From: kfrn Date: Mon, 2 Oct 2017 23:38:39 +1300 Subject: [PATCH 1/9] Fix-ups: inline links, grammar corrections, etc I've also moved the link to Dinah Handel's NDSR blog (http://ndsr.nycdigital.org/diving-in-head-first/) next to a different subcommand that it more directly relates to. --- index.html | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 439c688..583d458 100644 --- a/index.html +++ b/index.html @@ -198,8 +198,8 @@

Create FFV1 Version 3 video in a Matroska container with framemd5 of input-c:v ffv1
specifies the FFV1 video codec.
-level 3
specifies Version 3 of the FFV1 codec.
-g 1
specifies intra-frame encoding, or GOP=1.
-
-slicecrc 1
Adds CRC information for each slice. This makes it possible for a decoder to detect errors in the bitstream, rather than blindly decoding a broken slice.
-
-slices 16
Each frame is split into 16 slices. 16 is a good trade-off between filesize and encoding time. [more]
+
-slicecrc 1
Adds CRC information for each slice. This makes it possible for a decoder to detect errors in the bitstream, rather than blindly decoding a broken slice. (Read more here).
+
-slices 16
Each frame is split into 16 slices. 16 is a good trade-off between filesize and encoding time.
-c:a copy
copies all mapped audio streams.
output_file.mkv
path and name of the output file. Use the .mkv extension to save your file in a Matroska container. Optionally, choose a different extension if you want a different container, such as .mov or .avi.
-f framemd5
Decodes video with the framemd5 muxer in order to generate MD5 checksums for every frame of your input file. This allows you to verify losslessness when compared against the framemd5s of the output file.
@@ -286,7 +286,7 @@

Convert DVD to H.264

Transcode to H.265/HEVC

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

This command takes an input file and transcodes it to H.265/HEVC in an .mp4 wrapper, keeping the audio codec the same as in the original file.

-

Note: ffmpeg must be compiled with libx265, the library of the H.265 codec, for this script to work. (Add the flag --with-x265 if using brew install ffmpeg method).

+

Note: ffmpeg must be compiled with libx265, the library of the H.265 codec, for this script to work. (Add the flag --with-x265 if using the brew install ffmpeg method).

ffmpeg
starts the command
-i input file
path, name and extension of the input file
@@ -855,7 +855,7 @@

Create GIF

ffmpeg
starts the command
-ss HH:MM:SS
starting point of the GIF. If a plain numerical value is used it will be interpreted as seconds
-i input_file
path, name and extension of the input file
-
-filter_complex "fps=frame rate,scale=width:height,palettegen"
a complex filtergraph.
+
-filter_complex "fps=framerate,scale=width:height,palettegen"
a complex filtergraph.
Firstly, the fps filter sets the frame rate.
Then the scale filter resizes the image. You can specify both the width and the height, or specify a value for one and use a scale value of -1 for the other to preserve the aspect ratio. (For example, 500:-1 would create a GIF 500 pixels wide and with a height proportional to the original video). In the first script above, :flags=lanczos specifies that the Lanczos rescaling algorithm will be used to resize the image.
Lastly, the palettegen filter generates the palette.
@@ -1053,7 +1053,7 @@

Create ISO files for DVD access

- +
@@ -788,13 +797,13 @@

Plays vectorscope of video

ffplay
starts the command
input_file
path, name and extension of the input file
-vf
creates a filtergraph to use for the streams
-
"
quotation mark to start command
+
"
quotation mark to start filtergraph
split=2[m][v]
Splits the input into two identical outputs and names them [m] and [v]
,
comma signifies there is another parameter coming
[v]vectorscope=b=0.7:m=color3:g=green[v]
asserts usage of the vectorscope filter and sets a light background opacity (b, alias for bgopacity), sets a background color style (m, alias for mode), and graticule color (g, alias for graticule)
,
comma signifies there is another parameter coming
[m][v]overlay=x=W-w:y=H-h
declares where the vectorscope will overlay on top of the video image as it plays
-
"
quotation mark to end command
+
"
quotation mark to end filtergraph
@@ -815,9 +824,11 @@

This will play two input videos side by side while also applying the tempora
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)
+
"
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]
-
[a][b]hstack[out]
Takes the outputs from the previous steps ([a] and [b] and uses the hstack (horizontal stack) filter on them to create the side by side output. This output is then named [out])
+
[a][b]hstack[out]
Takes the outputs from the previous steps ([a] and [b] and uses the hstack (horizontal stack) filter on them to create the side by side output. This output is then named [out])
+
"
quotation mark to end filtergraph
-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
@@ -1601,7 +1612,7 @@

Make a test pattern video

-f lavfi
tells ffmpeg to use the libavfilter input virtual device
-i testsrc=size=720x576:rate=25
asks for the testsrc filter pattern as input. Adjusting the size and rate options allows you to choose a specific frame size and framerate.
The different test patterns that can be generated are listed here.
-
-c:v v210
transcodes video from rawvideo to 10-bit Uncompressed YUV 4:2:2. Alter this setting to set your desired codec.
+
-c:v v210
transcodes video from rawvideo to 10-bit Uncompressed Y′CBCR 4:2:2. Alter this setting to set your desired codec.
-t 10
specifies recording time of 10 seconds
output_file
path, name and extension of the output file. Try different file extensions such as mkv, mov, mp4, or avi.
@@ -1889,12 +1900,15 @@

Combine audio tracks into one in a video file

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-
-filter_complex [0:a:0][0:a:1]amerge[out]
combines the two audio tracks into one
-
-map 0:v
map the video
-
-map "[out]"
map the combined audio defined by the filter
-
-c:v copy
copy the video
+
-filter_complex
tells fmpeg that we will be using a complex filter
+
"
quotation mark to start filtergraph
+
[0:a:0][0:a:1]amerge[out]
combines the two audio tracks into one
+
"
quotation mark to end filtergraph
+
-map 0:v
map the video
+
-map "[out]"
map the combined audio defined by the filter
+
-c:v copy
copy the video
-shortest
limit to the shortest stream
-
video_output_file
path, name and extension of the video output file
+
output_file
path, name and extension of the video output file
@@ -1961,7 +1975,7 @@

Modify image and sound speed

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-
-filter_complex "[0:v]setpts=input_fps/output_fps*PTS[v]; [0:a]atempo=output_fps/input_fps[a]"
A complex filter is needed here, in order to handle video stream and the audio stream separately. The setpts video filter modifies the PTS (presentation time stamp) of the video stream, and the atempo audio filter modifies the speed of the audio stream while keeping the same sound pitch. Note that the parameter’s order for the image and for the sound are inverted: +
-filter_complex "[0:v]setpts=input_fps/output_fps*PTS[v]; [0:a]atempo=output_fps/input_fps[a]"
A complex filter is needed here, in order to handle video stream and the audio stream separately. The setpts video filter modifies the PTS (presentation time stamp) of the video stream, and the atempo audio filter modifies the speed of the audio stream while keeping the same sound pitch. Note that the parameter order for the image and for the sound are inverted:
  • In the video filter setpts the numerator input_fps sets the input speed and the denominator output_fps sets the output speed; both values are given in frames per second.
  • In the sound filter atempo the numerator output_fps sets the output speed and the denominator input_fps sets the input speed; both values are given in frames per second.
  • @@ -2038,24 +2052,24 @@

    Overlay image watermark on video

@@ -2102,7 +2116,7 @@

Create a video from an image and audio file.

-loop 1
loop the first input stream
-i image_file
path, name and extension of the image file
-i audio_file
path, name and extension of the audio file
-
-acodec copy
copy the audio. -acodec is an alias for -c:a
+
-acodec copy
copy the audio. -acodec is an alias for -c:a
-shortest
finish encoding when the shortest input stream ends
-vf scale=1280:720
filter the video to scale it to 1280x720 for YouTube. -vf is an alias for -filter:v
video_output_file
path, name and extension of the video output file
From 3a58b6ae828565bb01d7826ed4033381db3e9062 Mon Sep 17 00:00:00 2001 From: kfrn Date: Tue, 3 Oct 2017 01:10:28 +1300 Subject: [PATCH 3/9] Style: add spaces in long filtergraphs; only use italics for inputs In filtergraphs that are reasonably long or unwieldy, I've added a space after each comma for readability. In ffmpeg commands, italics should denote user inputs/outputs. Where italics had been used for 'regular' variables (i.e., not an input/output file or a variable for which the user must explicitly choose the value), I've deleted them. These are stylistic changes that, I think, make things more readable and/or more uniform. --- index.html | 90 +++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/index.html b/index.html index 4d0244f..1798154 100644 --- a/index.html +++ b/index.html @@ -156,23 +156,23 @@

Transcode to H.264

"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

@@ -561,7 +561,7 @@

Transcode video to a different colourspace

For example, to convert from Rec.601 to Rec.709, you would use -vf colormatrix=bt601:bt709.
output file
path, name and extension of the output file
-

Note: Converting between colourspaces with ffmpeg can be done via either the colormatrix or colorspace filters, with colorspace allowing finer control (individual setting of colourspace, transfer characteristics, primaries, range, pixel format, etc). See this entry on the ffmpeg wiki, and the ffmpeg documentation for colormatrix and colorspace.

+

Note: Converting between colourspaces with ffmpeg can be done via either the colormatrix or colorspace filters, with colorspace allowing finer control (individual setting of colourspace, transfer characteristics, primaries, range, pixel format, etc). See this entry on the ffmpeg wiki, and the ffmpeg documentation for colormatrix and colorspace.


Convert colourspace and embed colourspace metadata

ffmpeg -i input_file -c:v libx264 -vf colormatrix=src:dst -color_primaries val -color_trc val -colorspace val output_file

@@ -589,7 +589,7 @@
Examples
MediaInfo screenshots of colourspace metadata

Using this command it is possible to add Rec.709 tags to a file that is actually Rec.601 (etc), so apply with caution!

These commands are relevant for H.264 and H.265 videos, encoded with libx264 and libx265 respectively.

-

Note: If you wish to embed colourspace metadata without changing to another colourspace, omit -vf colormatrix=src:dst. However, since it is libx264/libx265 that writes the metadata, it’s not possible to add these tags without reencoding the video stream.

+

Note: If you wish to embed colourspace metadata without changing to another colourspace, omit -vf colormatrix=src:dst. However, since it is libx264/libx265 that writes the metadata, it’s not possible to add these tags without reencoding the video stream.

For all possible values for -color_primaries, -color_trc, and -colorspace, see the ffmpeg documentation on codec options.


1. Out of step with the regular pattern, -color_trc doesn’t accept bt470bg; it is instead here referred to directly as gamma.
@@ -679,7 +679,7 @@

Plays a graphical output showing decibel levels of an input file

ffplay -f lavfi "amovie='input.mp3', astats=metadata=1:reset=1, adrawgraph=lavfi.astats.Overall.Peak_level:max=0:min=-30.0:size=700x256:bg=Black[out]"

ffplay
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffplay to use the Libavfilter input virtual device
"
quotation mark to start the lavfi filtergraph
movie='input.mp3'
declares audio source file on which to apply filter
,
comma signifies the end of audio source section and the beginning of the filter section
@@ -713,7 +713,7 @@

Shows all pixels outside of broadcast range

ffplay -f lavfi "movie='input.mp4', signalstats=out=brng:color=cyan[out]"

ffplay
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffplay to use the Libavfilter input virtual device
"
quotation mark to start the lavfi filtergraph
movie='input.mp4'
declares video file source to apply filter
,
comma signifies closing of video source assertion and ready for filter assertion
@@ -775,7 +775,7 @@

Exports OCR data to screen

ffprobe
starts the command
-show_entries
sets a list of entries to show
frame_tags=lavfi.ocr.text
shows the lavfi.ocr.text tag in the frame section of the video
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffprobe to use the Libavfilter input virtual device
-i "movie=input_file,ocr"
declares 'movie' as input_file and passes in the 'ocr' command
@@ -975,7 +975,7 @@

Trim a video without re-encoding

-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. + 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

@@ -1279,7 +1279,7 @@

Create Bash script to batch process with ffmpeg

"${file%.mxf}.mov";
retaining the original file name, set the output file wrapper as .mov
done
complete; all items have been processed.
-

Note: the shell script (.sh file) and all .mxf files to be processed must be contained within the same directory, and the script must be run from that directory.
+

Note: the shell script (.sh file) and all .mxf files to be processed must be contained within the same directory, and the script must be run from that directory.
Execute the .sh file with the command sh Rewrap-MXF.sh.

Modify the script as needed to perform different transcodes, or to use with ffprobe. :)

The basic pattern will look similar to this:
@@ -1317,13 +1317,13 @@

Create PowerShell script to batch process with ffmpeg

{
Opens the code block.
$output = [io.path]::ChangeExtension($file, '.mkv')
Sets up the output file: it will be located in the current folder and keep the same filename, but will have an .mkv extension instead of .mp4.
ffmpeg -i $file
Carry out the following ffmpeg command for each input file.
- Note: To call ffmpeg here as just ‘ffmpeg’ (rather than entering the full path to ffmpeg.exe), you must make sure that it’s correctly configured. See this article, especially the section ‘Add to Path’.
+ Note: To call ffmpeg here as just ‘ffmpeg’ (rather than entering the full path to ffmpeg.exe), you must make sure that it’s correctly configured. See this article, especially the section ‘Add to Path’.
-map 0
retain all streams
-c copy
enable stream copy (no re-encode)
$output
The output file is set to the value of the $output variable declared above: i.e., the current file name with an .mkv extension.
}
Closes the code block.
-

Note: the PowerShell script (.ps1 file) and all .mp4 files to be rewrapped must be contained within the same directory, and the script must be run from that directory.

+

Note: the PowerShell script (.ps1 file) and all .mp4 files to be rewrapped must be contained within the same directory, and the script must be run from that directory.

Execute the .ps1 file by typing .\rewrap-mp4.ps1 in PowerShell.

Modify the script as needed to perform different transcodes, or to use with ffprobe. :)

@@ -1470,7 +1470,7 @@

Creates a QCTools report

This will create an XML report for use in QCTools for a video file with one video track and one audio track. See also the QCTools documentation.

ffprobe
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffprobe to use the Libavfilter input virtual device
-i
input file and parameters
"movie=input_file:s=v+a[in0][in1], [in0]signalstats=stat=tout+vrep+brng, cropdetect=reset=1:round=1, idet=half_life=1, split[a][b];[a]field=top[a1];[b]field=bottom, split[b1][b2];[a1][b1]psnr[c1];[c1][b2]ssim[out0];[in1]ebur128=metadata=1, astats=metadata=1:reset=1:length=0.4[out1]"
This very large lump of commands declares the input file and passes in a request for all potential data signal information for a file with one video and one audio track
@@ -1500,7 +1500,7 @@

Creates a QCTools report

This will create an XML report for use in QCTools for a video file with one video track and NO audio track. See also the QCTools documentation.

ffprobe
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffprobe to use the Libavfilter input virtual device
-i
input file and parameters
"movie=input_file,signalstats=stat=tout+vrep+brng, cropdetect=reset=1:round=1, idet=half_life=1, split[a][b];[a]field=top[a1];[b]field=bottom,split[b1][b2];[a1][b1]psnr[c1];[c1][b2]ssim"
This very large lump of commands declares the input file and passes in a request for all potential data signal information for a file with one video and one audio track
@@ -1634,7 +1634,7 @@

Play HD SMPTE bars

ffplay -f lavfi -i smptehdbars=size=1920x1080

ffplay
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffplay to use the Libavfilter input virtual device
-i smptehdbars=size=1920x1080
asks for the smptehdbars filter pattern as input and sets the HD resolution. This generates a colour bars pattern, based on the SMPTE RP 219–2002.
@@ -1655,7 +1655,7 @@

Play VGA SMPTE bars

ffplay -f lavfi -i smptebars=size=640x480

ffplay
starts the command
-
-f lavfi
tells ffmpeg to use the Libavfilter input virtual device
+
-f lavfi
tells ffplay to use the Libavfilter input virtual device
-i smptebars=size=640x480
asks for the smptebars filter pattern as input and sets the VGA (SD) resolution. This generates a colour bars pattern, based on the SMPTE Engineering Guideline EG 1–1990.
@@ -1788,7 +1788,7 @@

Join files together

. . . file './last_file.ext' In the above, file is simply the word "file". Straight apostrophes ('like this') rather than curved quotation marks (‘like this’) must be used to enclose the file paths.
-Note: If specifying absolute file paths in the .txt file, add -safe 0 before the input file.
+Note: If specifying absolute file paths in the .txt file, add -safe 0 before the input file.
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
@@ -1849,12 +1849,12 @@

Play an image sequence

ffplay
starts the command
-framerate 5
plays image sequence at rate of 5 images per second
- Note: this low framerate will produce a slideshow effect.
+ Note: this low framerate will produce a slideshow effect.
-i input_file
path, name and extension of the input file
This must match the naming convention used! The regex %06d matches six-digit-long numbers, possibly with leading zeroes. This allows the full sequence to be read in ascending order, one image after the other.
The extension for TIFF files is .tif or maybe .tiff; the extension for DPX files is .dpx (or even .cin for old files). Screenshots are often in .png format.
-

Notes:

+

Notes:

If -framerate is omitted, the playback speed depends on the images’ file sizes and on the computer’s processing power. It may be rather slow for large image files.

You can navigate durationally by clicking within the playback window. Clicking towards the left-hand side of the playback window takes you towards the beginning of the playback sequence; clicking towards the right takes you towards the end of the sequence.

@@ -2069,7 +2069,7 @@

Create a burnt in timecode on your image

"
quotation mark to end drawtext filter command
output_file
path, name and extension of the output file.
-

Note: -vf is a shortcut for -filter:v.

+

Note: -vf is a shortcut for -filter:v.

From da9455732418aa5c79f29f3ed9f9b039278e9e49 Mon Sep 17 00:00:00 2001 From: kfrn Date: Wed, 4 Oct 2017 21:39:18 +1300 Subject: [PATCH 5/9] Reorganise ffmpeg commands under more/different subheadings --- index.html | 1526 ++++++++++++++++++++++++++-------------------------- 1 file changed, 774 insertions(+), 752 deletions(-) diff --git a/index.html b/index.html index 6132db1..e59e7c0 100644 --- a/index.html +++ b/index.html @@ -46,7 +46,7 @@

What do you want to do?

-

Change container (rewrap)

+

Change container (rewrap)

@@ -77,7 +77,7 @@

MKV to MP4

-

Change codec (transcode)

+

Change codec (transcode)

@@ -372,36 +372,7 @@

WAV to AAC/MP4

-

Change formats

- - - - - +

Change video properties

@@ -503,46 +474,6 @@

Change Display Aspect Ratio without reencoding video

- - - - - - - - +
+

Join, trim, or excerpt a video

+ + + + - - -
-
-

Filters

+ - - -