Changes between Version 51 and Version 52 of FilteringGuide


Ignore:
Timestamp:
Nov 28, 2019, 12:03:29 PM (7 years ago)
Author:
slhck
Comment:

reorder sections, move syntax explanations to syntax; they're not examples

Legend:

Unmodified
Added
Removed
Modified
  • FilteringGuide

    v51 v52  
    2626ffmpeg -i input -vf scale=iw/2:-1 output
    2727}}}
    28 FFmpeg assumes the option names in the order they are declared in the source code.  For instance, in this use of the [http://ffmpeg.org/ffmpeg-filters.html#scale scale filter], FFmpeg assumes the option name `width` for the value `iw/2`, and the name `height` for the value `-1`.
    29 
    30 == Examples ==
    31 
    32 === Scaling ===
    33 Starting with something simple. Resize a 640x480 input to a 320x240 output.
    34 {{{
    35 ffmpeg -i input -vf scale=iw/2:-1 output
    36 }}}
    37 `iw` is input width. In this example the input width is 640. 640/2 = 320. The `-1` tells the scale filter to preserve the aspect ratio of the output, so in this example the scale filter will choose a value of 240. See the [http://ffmpeg.org/ffmpeg-filters.html#scale FFmpeg documentation] for additional information.
    38 
    39 === Speed up your video ===
    40 
    41 See [[How to speed up / slow down a video]] for examples.
    42 
    43 === Filtergraph,Chain,Filter relationship ===
     28FFmpeg assumes the option names in the order they are declared in the source code.  For instance, in this use of the [http://ffmpeg.org/ffmpeg-filters.html#scale scale filter], FFmpeg assumes the option name `width` for the value `iw/2`, and the name `height` for the value `-1`.
     29
     30=== Filtergraph, Chain, Filter relationship ===
     31
    4432What follows the `-vf` in an ffmpeg command line is a [http://ffmpeg.org/ffmpeg-filters.html#Filtergraph-description filtergraph] description. This filtergraph may contain a number of chains, each of which may contain a number of filters.
    4533
     
    6149}}}
    6250
    63 === multiple input overlay in 2x2 grid ===
     51=== Escaping characters ===
     52
     53As described in the documentation, it can be necessary to escape commas "," that need to appear in some arguments, for example the select filter:
     54
     55{{{
     56ffmpeg -i input -vf select='eq(pict_type\,I)' -vsync vfr output_%04d.png        # to select only I frames
     57}}}
     58
     59However an alternative, which also allows for white space within the filtergraph, and which may assist in clarity of reading complex graphs, is to enclose the whole filtergraph within double quotes " " thus:
     60
     61{{{
     62ffmpeg -i input -vf "select='eq(pict_type,I)'" output       # to select only I frames
     63ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output    # deinterlace then resize
     64}}}
     65
     66Note that the examples given in the documentation mix and match the use of "full quoting" and "\" escaping, and that use of unusual shells may upset escaping. See [http://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping Notes on filtergraph escaping] for more information.
     67
     68== Examples ==
     69
     70=== Scaling ===
     71Starting with something simple. Resize a 640x480 input to a 320x240 output.
     72{{{
     73ffmpeg -i input -vf scale=iw/2:-1 output
     74}}}
     75`iw` is input width. In this example the input width is 640. 640/2 = 320. The `-1` tells the scale filter to preserve the aspect ratio of the output, so in this example the scale filter will choose a value of 240. See the [http://ffmpeg.org/ffmpeg-filters.html#scale FFmpeg documentation] for additional information.
     76
     77=== Speed up your video ===
     78
     79See [[How to speed up / slow down a video]] for examples.
     80
     81=== Multiple input overlay in 2x2 grid ===
    6482
    6583[[Image(multiple_input_overlay.jpg)]]
     
    94112Be aware that frames are taken from each input video in timestamp order, so it is a good idea to pass all overlay inputs through a `setpts=PTS-STARTPTS` filter to have them begin in the same zero timestamp, such as `[0:v]hflip,setpts=PTS-STARTPTS[a];[1:v]setpts=PTS-STARTPTS[b];[a][b]overlay`.
    95113
    96 === Escaping characters ===
    97 As described in the documentation, it can be necessary to escape commas "," that need to appear in some arguments, for example the select filter:
    98 {{{
    99 ffmpeg -i input -vf select='eq(pict_type\,I)' -vsync vfr output_%04d.png        # to select only I frames
    100 }}}
    101 
    102 However an alternative, which also allows for white space within the filtergraph, and which may assist in clarity of reading complex graphs, is to enclose the whole filtergraph within double quotes " " thus:
    103 {{{
    104 ffmpeg -i input -vf "select='eq(pict_type,I)'" output       # to select only I frames
    105 ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output    # deinterlace then resize
    106 }}}
    107 Note that the examples given in the documentation mix and match the use of "full quoting" and "\" escaping, and that use of unusual shells may upset escaping. See [http://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping Notes on filtergraph escaping] for more information.
    108 
    109114=== Burnt in Timecode ===
    110115Using the [http://ffmpeg.org/ffmpeg-filters.html#drawtext-1 drawtext] video filter.