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
346b2323
Commit
346b2323
authored
Oct 15, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_silenceremove: add mode options
To control how threshold is calculated in multichannel audio.
parent
c07bc1d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
af_silenceremove.c
libavfilter/af_silenceremove.c
+27
-6
No files found.
libavfilter/af_silenceremove.c
View file @
346b2323
...
...
@@ -49,6 +49,7 @@ typedef struct SilenceRemoveContext {
double
start_threshold
;
int64_t
start_silence
;
int64_t
start_silence_opt
;
int
start_mode
;
int
stop_periods
;
int64_t
stop_duration
;
...
...
@@ -56,6 +57,7 @@ typedef struct SilenceRemoveContext {
double
stop_threshold
;
int64_t
stop_silence
;
int64_t
stop_silence_opt
;
int
stop_mode
;
double
*
start_holdoff
;
double
*
start_silence_hold
;
...
...
@@ -96,10 +98,14 @@ static const AVOption silenceremove_options[] = {
{
"start_duration"
,
NULL
,
OFFSET
(
start_duration_opt
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
},
0
,
INT32_MAX
,
AF
},
{
"start_threshold"
,
NULL
,
OFFSET
(
start_threshold
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
},
0
,
DBL_MAX
,
AF
},
{
"start_silence"
,
NULL
,
OFFSET
(
start_silence_opt
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
},
0
,
INT32_MAX
,
AF
},
{
"start_mode"
,
NULL
,
OFFSET
(
start_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
AF
,
"mode"
},
{
"any"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
AF
,
"mode"
},
{
"all"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
AF
,
"mode"
},
{
"stop_periods"
,
NULL
,
OFFSET
(
stop_periods
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
-
9000
,
9000
,
AF
},
{
"stop_duration"
,
NULL
,
OFFSET
(
stop_duration_opt
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
},
0
,
INT32_MAX
,
AF
},
{
"stop_threshold"
,
NULL
,
OFFSET
(
stop_threshold
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
},
0
,
DBL_MAX
,
AF
},
{
"stop_silence"
,
NULL
,
OFFSET
(
stop_silence_opt
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
},
0
,
INT32_MAX
,
AF
},
{
"stop_mode"
,
NULL
,
OFFSET
(
stop_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
AF
,
"mode"
},
{
"detection"
,
NULL
,
OFFSET
(
detection
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
0
,
1
,
AF
,
"detection"
},
{
"peak"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
AF
,
"detection"
},
{
"rms"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
AF
,
"detection"
},
...
...
@@ -320,9 +326,16 @@ silence_trim:
break
;
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
threshold
=
0
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
if
(
s
->
start_mode
)
{
threshold
=
0
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
}
}
else
{
threshold
=
1
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
}
}
if
(
threshold
)
{
...
...
@@ -428,9 +441,17 @@ silence_copy:
if
(
s
->
stop_periods
)
{
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
threshold
=
1
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
if
(
s
->
stop_mode
)
{
threshold
=
0
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
}
}
else
{
threshold
=
1
;
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
}
}
if
(
threshold
&&
s
->
stop_holdoff_end
&&
!
s
->
stop_silence
)
{
s
->
mode
=
SILENCE_COPY_FLUSH
;
...
...
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