Changes between Version 46 and Version 47 of FilteringGuide
- Timestamp:
- Nov 1, 2016, 6:49:14 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FilteringGuide
v46 v47 42 42 43 43 === multiple input overlay in 2x2 grid === 44 45 [[Image(multiple_input_overlay.jpg)]] 46 44 47 Here 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. 45 48 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].49 Within 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. 47 50 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 {{{ 52 ffmpeg -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 }}} 49 60 50 [[Image(multiple_input_overlay.jpg)]] 61 This 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 51 63 {{{ 52 64 ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -filter_complex \ … … 65 77 As described in the documentation, it can be necessary to escape commas "," that need to appear in some arguments, for example the select filter: 66 78 {{{ 67 ffmpeg -i input -vf select='eq(pict_type\, PICT_TYPE_I)' output# to select only I frames79 ffmpeg -i input -vf select='eq(pict_type\,I)' -vsync vfr output_%04d.png # to select only I frames 68 80 }}} 69 81 70 82 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: 71 83 {{{ 72 ffmpeg -i input -vf "select= eq(pict_type,PICT_TYPE_I)" output# to select only I frames73 ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output # deinterlace then resize84 ffmpeg -i input -vf "select='eq(pict_type,I)'" output # to select only I frames 85 ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output # deinterlace then resize 74 86 }}} 75 87 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. … … 157 169 === Other Filter Examples === 158 170 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. 160 172 * [[Null]] describes the nullsink filter. 161 173
