Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
d54276f9
Commit
d54276f9
authored
Dec 16, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_apad: add pad_dur and whole_dur options
parent
ee1e39a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
filters.texi
doc/filters.texi
+15
-3
af_apad.c
libavfilter/af_apad.c
+21
-2
No files found.
doc/filters.texi
View file @
d54276f9
...
...
@@ -1776,11 +1776,23 @@ Set the minimum total number of samples in the output audio stream. If
the value is longer than the input audio length, silence is added to
the end, until the value is reached. This option is mutually exclusive
with @option{pad_len}.
@item pad_dur
Specify the duration of samples of silence to add. See
@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
for the accepted syntax. Used only if set to non-zero value.
@item whole_dur
Specify the minimum total duration in the output audio stream. See
@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
for the accepted syntax. Used only if set to non-zero value. If the value is longer than
the input audio length, silence is added to the end, until the value is reached.
This option is mutually exclusive with @option{pad_dur}
@end table
If neither the @option{pad_len} nor the @option{whole_len}
option is
set, the filter will add silence to the end of the input stream
indefinitely.
If neither the @option{pad_len} nor the @option{whole_len}
nor @option{pad_dur}
nor @option{whole_dur} option is set, the filter will add silence to the end of
the input stream
indefinitely.
@subsection Examples
...
...
libavfilter/af_apad.c
View file @
d54276f9
...
...
@@ -41,6 +41,8 @@ typedef struct APadContext {
int
packet_size
;
int64_t
pad_len
,
pad_len_left
;
int64_t
whole_len
,
whole_len_left
;
int64_t
pad_dur
;
int64_t
whole_dur
;
}
APadContext
;
#define OFFSET(x) offsetof(APadContext, x)
...
...
@@ -50,6 +52,8 @@ static const AVOption apad_options[] = {
{
"packet_size"
,
"set silence packet size"
,
OFFSET
(
packet_size
),
AV_OPT_TYPE_INT
,
{
.
i64
=
4096
},
0
,
INT_MAX
,
A
},
{
"pad_len"
,
"set number of samples of silence to add"
,
OFFSET
(
pad_len
),
AV_OPT_TYPE_INT64
,
{
.
i64
=
-
1
},
-
1
,
INT64_MAX
,
A
},
{
"whole_len"
,
"set minimum target number of samples in the audio stream"
,
OFFSET
(
whole_len
),
AV_OPT_TYPE_INT64
,
{
.
i64
=
-
1
},
-
1
,
INT64_MAX
,
A
},
{
"pad_dur"
,
"set duration of silence to add"
,
OFFSET
(
pad_dur
),
AV_OPT_TYPE_DURATION
,
{
.
i64
=
0
},
0
,
INT64_MAX
,
A
},
{
"whole_dur"
,
"set minimum target duration in the audio stream"
,
OFFSET
(
whole_dur
),
AV_OPT_TYPE_DURATION
,
{
.
i64
=
0
},
0
,
INT64_MAX
,
A
},
{
NULL
}
};
...
...
@@ -64,8 +68,6 @@ static av_cold int init(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_ERROR
,
"Both whole and pad length are set, this is not possible
\n
"
);
return
AVERROR
(
EINVAL
);
}
s
->
pad_len_left
=
s
->
pad_len
;
s
->
whole_len_left
=
s
->
whole_len
;
return
0
;
}
...
...
@@ -131,6 +133,22 @@ static int request_frame(AVFilterLink *outlink)
return
ret
;
}
static
int
config_output
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
APadContext
*
s
=
ctx
->
priv
;
if
(
s
->
pad_dur
)
s
->
pad_len
=
av_rescale
(
s
->
pad_dur
,
outlink
->
sample_rate
,
AV_TIME_BASE
);
if
(
s
->
whole_dur
)
s
->
whole_len
=
av_rescale
(
s
->
whole_dur
,
outlink
->
sample_rate
,
AV_TIME_BASE
);
s
->
pad_len_left
=
s
->
pad_len
;
s
->
whole_len_left
=
s
->
whole_len
;
return
0
;
}
static
const
AVFilterPad
apad_inputs
[]
=
{
{
.
name
=
"default"
,
...
...
@@ -144,6 +162,7 @@ static const AVFilterPad apad_outputs[] = {
{
.
name
=
"default"
,
.
request_frame
=
request_frame
,
.
config_props
=
config_output
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
},
{
NULL
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment