Changes between Version 46 and Version 47 of FilteringGuide


Ignore:
Timestamp:
Nov 1, 2016, 8:49:14 PM (14 months ago)
Author:
llogan
Comment:

added hstack+vstack example and some minor changes

Legend:

Unmodified
Added
Removed
Modified
  • FilteringGuide

    v46 v47  
    4242 
    4343=== multiple input overlay in 2x2 grid === 
     44 
     45[[Image(multiple_input_overlay.jpg)]] 
     46 
    4447Here four inputs are filtered together using the `-filter_complex` option. In this case all of the inputs are the `-f lavfi -i testsrc` (the [https://ffmpeg.org/ffmpeg-filters.html#color_002c-haldclutsrc_002c-nullsrc_002c-rgbtestsrc_002c-smptebars_002c-smptehdbars_002c-testsrc testsrc source filter]) but could be other inputs. 
    4548 
    46 Within the filtergraph the first input is padded to the right and bottom by double its height, and the other three inputs are individually filtered using [https://ffmpeg.org/ffmpeg-filters.html#hflip hflip], [https://ffmpeg.org/ffmpeg-filters.html#negate negate], and [https://ffmpeg.org/ffmpeg-filters.html#edgedetect edgedetect]. 
     49Within the filtergraph the first input is unchanged, and the other three inputs are individually filtered using [https://ffmpeg.org/ffmpeg-filters.html#hflip hflip], [https://ffmpeg.org/ffmpeg-filters.html#negate negate], and [https://ffmpeg.org/ffmpeg-filters.html#edgedetect edgedetect]. The [https://ffmpeg.org/ffmpeg-filters.html#hstack hstack] and [https://ffmpeg.org/ffmpeg-filters.html#vstack vstack] filters are then used to stack each video into the desired location. 
    4750 
    48 The [https://ffmpeg.org/ffmpeg-filters.html#overlay-1 overlay] video filter is then used multiple times for placement of each input. The offsets used in the overlay filter arrange the inputs into a grid shape. 
     51{{{ 
     52ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -filter_complex \ 
     53"[1:v]negate[a]; \ 
     54 [2:v]hflip[b]; \ 
     55 [3:v]edgedetect[c]; \ 
     56 [0:v][a]hstack=inputs=2[top]; \ 
     57 [b][c]hstack=inputs=2[bottom]; \ 
     58 [top][bottom]vstack=inputs=2[out]" -map "[out]" -c:v ffv1 -t 5 multiple_input_grid.avi 
     59}}} 
    4960 
    50 [[Image(multiple_input_overlay.jpg)]] 
     61This next example is the same as above, but uses the [https://ffmpeg.org/ffmpeg-filters.html#pad pad] and [https://ffmpeg.org/ffmpeg-filters.html#overlay-1 overlay] filters instead. The pad filter is used to make an appropriate sized background, and overlay is used to place each video into the correct location. This method is slower than using hstack + vstack as shown above. 
     62 
    5163{{{ 
    5264ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -filter_complex \ 
     
    6577As described in the documentation, it can be necessary to escape commas "," that need to appear in some arguments, for example the select filter: 
    6678{{{ 
    67 ffmpeg -i input -vf select='eq(pict_type\,PICT_TYPE_I)' output                         # to select only I frames 
     79ffmpeg -i input -vf select='eq(pict_type\,I)' -vsync vfr output_%04d.png        # to select only I frames 
    6880}}} 
    6981 
    7082However 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: 
    7183{{{ 
    72 ffmpeg -i input -vf "select=eq(pict_type,PICT_TYPE_I)" output                # to select only I frames 
    73 ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output                     # deinterlace then resize 
     84ffmpeg -i input -vf "select='eq(pict_type,I)'" output       # to select only I frames 
     85ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output    # deinterlace then resize 
    7486}}} 
    7587Note 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. 
     
    157169=== Other Filter Examples === 
    158170 
    159  * [[FancyFilteringExamples|Fancy Filtering Examples]] – Examples for various psychedelic effects and other weird filtering. 
     171* [[FancyFilteringExamples|Fancy Filtering Examples]] – Examples for various psychedelic effects and other weird filtering. 
    160172*  [[Null]] describes the nullsink filter. 
    161173