Commit be6cdf7
lavf/qsv: Support multiple inputs overlay composition
Based on patch by Liu, ChaoX.
lavfi/vf_overlay_qsv: support mulit-inputs overlay.
Description:
1. layout(grid/manual/overlay) default is the preset 'overlay' mode
2. x_expr,y_expr,w_expr,z_expr,a_expr
If layout is set to overlay, these exprs will be used to calculate
the [overlay] channel's output rect while the [main] channle will be
forced the same as the 1st input.
If layout is set to manual, these expressions will be used to
construct the layout. Some const keys and funcs can be used.
If keyword 'array' is used, the expressions must have enough
comma-seprated statements to cover each input or it will cause an error.
Otherwise, the single statement will be applied to each window.
3. Const values
@array(\,) x_expr=array(expr1\,expr2\,...\,exprn) an array of
expressions indicating each windows x/y/w/h
@x(n),y(n),w(n),h(n),alpha(n),iw(n),ih(n) a group of functions that can get
each windows position attributions, where n indicates the index
counting from 0.
@n,n Const values, N indicates the number of input windows while n
indicates the index of current window.
Examples:
1. ffmpeg -hwaccel qsv -c:v h264_qsv -i test.mp4 -filter_complex
"split=4,overlay_qsv=4:manual:x_expr=w(n)*mod(n\,ceil(sqrt(N))):y_expr=h(n)*floor(n/ceil(sqrt(N))):w_expr=W/ceil(sqrt(N)):h_expr=H/ceil(sqrt(N))"
-preset veryfast -c:v h264_qsv output.mp4
When calculating the layout, 'n' will be replaced by the index of current window and this is the way how 'grid' mode calculate.
2. ffmpeg -hwaccel qsv -c:v h264_qsv -i test.mp4 -filter_complex
"split=4,overlay_qsv=4:manual:x_expr=array(0\,960\,0,960):y_expr=array(0\,0\,540\,540):w_expr=array(960,960,960,960):h_expr=array(540,540,540,540):a_expr=255"
-preset veryfast -c:v h264_qsv output.mp4
This command is equal to the former one when test.mp4 is of FHD.
3. to overlay a video to area [(0,0), (256,256)] on another video, you can use:
ffmpeg -hwaccel qsv -c:v h264_qsv -i test1.mp4 -hwaccel qsv -c:v h264_qsv -i test2.mp4 -filter_complex
"overlay_qsv=x_expr=0:y_expr=0:w_expr=256:h_expr=256:a_expr=128" -preset veryfast -c:v h264_qsv output.mp4
Signed-off-by: Ruiling Song <ruiling.song@intel.com>1 parent c194242 commit be6cdf7
2 files changed
Lines changed: 386 additions & 201 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
34 | 47 | | |
35 | 48 | | |
36 | 49 | | |
| |||
0 commit comments