Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
b9dfee9f
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b9dfee9f
编写于
2月 25, 2013
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vf_fade: switch to an AVOptions-based system.
上级
8ec464c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
34 deletion
+53
-34
doc/filters.texi
doc/filters.texi
+18
-14
libavfilter/vf_fade.c
libavfilter/vf_fade.c
+35
-20
未找到文件。
doc/filters.texi
浏览文件 @
b9dfee9f
...
...
@@ -1000,33 +1000,37 @@ For more information about libfreetype, check:
Apply fade-in/out effect to input video.
It accepts the parameters:
@var{type}:@var{start_frame}:@var{nb_frames}
This filter accepts the following options:
@table @option
@var{type} specifies if the effect type, can be either "in" for
fade-in, or "out" for a fade-out effect.
@item type
The effect type -- can be either "in" for fade-in, or "out" for a fade-out
effect.
@item start_frame
The number of the start frame for starting to apply the fade effect.
@var{start_frame} specifies the number of the start frame for starting
to apply the fade effect.
@item nb_frames
The number of frames for which the fade effect has to last. At the end of the
fade-in effect the output video will have the same intensity as the input video,
at the end of the fade-out transition the output video will be completely black.
@var{nb_frames} specifies the number of frames for which the fade
effect has to last. At the end of the fade-in effect the output video
will have the same intensity as the input video, at the end of the
fade-out transition the output video will be completely black.
@end table
A few usage examples follow, usable too as test scenarios.
@example
# fade in first 30 frames of video
fade=
in:0:
30
fade=
type=in:nb_frames=
30
# fade out last 45 frames of a 200-frame video
fade=
out:155:
45
fade=
type=out:start_frame=155:nb_frames=
45
# fade in first 25 frames and fade out last 25 frames of a 1000-frame video
fade=
in:0:25, fade=out:975:
25
fade=
type=in:start_frame=0:nb_frames=25, fade=type=out:start_frame=975:nb_frames=
25
# make first 5 frames black, then fade in from frame 5-24
fade=
in:5:
20
fade=
type=in:start_frame=5:nb_frames=
20
@end example
@section fieldorder
...
...
libavfilter/vf_fade.c
浏览文件 @
b9dfee9f
...
...
@@ -26,48 +26,42 @@
*/
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#define FADE_IN 0
#define FADE_OUT 1
typedef
struct
{
const
AVClass
*
class
;
int
type
;
int
factor
,
fade_per_frame
;
unsigned
int
frame_index
,
start_frame
,
stop_frame
;
int
start_frame
,
nb_frames
;
unsigned
int
frame_index
,
stop_frame
;
int
hsub
,
vsub
,
bpp
;
}
FadeContext
;
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
FadeContext
*
fade
=
ctx
->
priv
;
unsigned
int
nb_frames
;
char
in_out
[
4
];
if
(
!
args
||
sscanf
(
args
,
" %3[^:]:%u:%u"
,
in_out
,
&
fade
->
start_frame
,
&
nb_frames
)
!=
3
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Expected 3 arguments '(in|out):#:#':'%s'
\n
"
,
args
);
return
AVERROR
(
EINVAL
);
}
nb_frames
=
nb_frames
?
nb_frames
:
1
;
fade
->
fade_per_frame
=
(
1
<<
16
)
/
nb_frames
;
if
(
!
strcmp
(
in_out
,
"in"
))
fade
->
fade_per_frame
=
(
1
<<
16
)
/
fade
->
nb_frames
;
if
(
fade
->
type
==
FADE_IN
)
{
fade
->
factor
=
0
;
else
if
(
!
strcmp
(
in_out
,
"out"
)
)
{
}
else
if
(
fade
->
type
==
FADE_OUT
)
{
fade
->
fade_per_frame
=
-
fade
->
fade_per_frame
;
fade
->
factor
=
(
1
<<
16
);
}
else
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"first argument must be 'in' or 'out':'%s'
\n
"
,
in_out
);
return
AVERROR
(
EINVAL
);
}
fade
->
stop_frame
=
fade
->
start_frame
+
nb_frames
;
fade
->
stop_frame
=
fade
->
start_frame
+
fade
->
nb_frames
;
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"type:%s start_frame:%d nb_frames:%d
\n
"
,
in_out
,
fade
->
start_frame
,
nb_frames
);
fade
->
type
==
FADE_IN
?
"in"
:
"out"
,
fade
->
start_frame
,
fade
->
nb_frames
);
return
0
;
}
...
...
@@ -143,6 +137,26 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
return
ff_filter_frame
(
inlink
->
dst
->
outputs
[
0
],
frame
);
}
#define OFFSET(x) offsetof(FadeContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static
const
AVOption
options
[]
=
{
{
"type"
,
"'in' or 'out' for fade-in/fade-out"
,
OFFSET
(
type
),
AV_OPT_TYPE_INT
,
{
.
i64
=
FADE_IN
},
FADE_IN
,
FADE_OUT
,
FLAGS
,
"type"
},
{
"in"
,
"fade-in"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
FADE_IN
},
.
unit
=
"type"
},
{
"out"
,
"fade-out"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
FADE_OUT
},
.
unit
=
"type"
},
{
"start_frame"
,
"Number of the first frame to which to apply the effect."
,
OFFSET
(
start_frame
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
0
,
INT_MAX
,
FLAGS
},
{
"nb_frames"
,
"Number of frames to which the effect should be applied."
,
OFFSET
(
nb_frames
),
AV_OPT_TYPE_INT
,
{
.
i64
=
1
},
0
,
INT_MAX
,
FLAGS
},
{
NULL
},
};
static
const
AVClass
fade_class
=
{
.
class_name
=
"fade"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
const
AVFilterPad
avfilter_vf_fade_inputs
[]
=
{
{
.
name
=
"default"
,
...
...
@@ -168,6 +182,7 @@ AVFilter avfilter_vf_fade = {
.
description
=
NULL_IF_CONFIG_SMALL
(
"Fade in/out input video"
),
.
init
=
init
,
.
priv_size
=
sizeof
(
FadeContext
),
.
priv_class
=
&
fade_class
,
.
query_formats
=
query_formats
,
.
inputs
=
avfilter_vf_fade_inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录