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
56b2731a
Commit
56b2731a
authored
Feb 19, 2018
by
Nicolas Gaullier
Committed by
Paul B Mahol
Mar 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/silencedetect: Fix silence_start accuracy
parent
cd4756a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
15 deletions
+18
-15
af_silencedetect.c
libavfilter/af_silencedetect.c
+5
-2
filter-metadata-silencedetect
tests/ref/fate/filter-metadata-silencedetect
+13
-13
No files found.
libavfilter/af_silencedetect.c
View file @
56b2731a
...
...
@@ -37,6 +37,7 @@ typedef struct SilenceDetectContext {
double
noise
;
///< noise amplitude ratio
double
duration
;
///< minimum duration of silence until notification
int
mono
;
///< mono mode : check each channel separately (default = check when ALL channels are silent)
int
channels
;
///< number of channels
int
independant_channels
;
///< number of entries in following arrays (always 1 in mono mode)
int64_t
*
nb_null_samples
;
///< (array) current number of continuous zero samples
int64_t
*
start
;
///< (array) if silence is detected, this value contains the time of the first zero sample (default/unset = INT64_MIN)
...
...
@@ -79,7 +80,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples,
if
(
s
->
start
[
channel
]
==
INT64_MIN
)
{
s
->
nb_null_samples
[
channel
]
++
;
if
(
s
->
nb_null_samples
[
channel
]
>=
nb_samples_notify
)
{
s
->
start
[
channel
]
=
insamples
->
pts
-
(
int64_t
)(
s
->
duration
/
av_q2d
(
time_base
)
+
.
5
);
s
->
start
[
channel
]
=
insamples
->
pts
+
av_rescale_q
(
current_sample
/
s
->
channels
+
1
-
nb_samples_notify
*
s
->
independant_channels
/
s
->
channels
,
(
AVRational
){
1
,
s
->
last_sample_rate
},
time_base
);
set_meta
(
insamples
,
s
->
mono
?
channel
+
1
:
0
,
"silence_start"
,
av_ts2timestr
(
s
->
start
[
channel
],
&
time_base
));
if
(
s
->
mono
)
...
...
@@ -132,7 +134,8 @@ static int config_input(AVFilterLink *inlink)
SilenceDetectContext
*
s
=
ctx
->
priv
;
int
c
;
s
->
independant_channels
=
s
->
mono
?
inlink
->
channels
:
1
;
s
->
channels
=
inlink
->
channels
;
s
->
independant_channels
=
s
->
mono
?
s
->
channels
:
1
;
s
->
nb_null_samples
=
av_mallocz_array
(
sizeof
(
*
s
->
nb_null_samples
),
s
->
independant_channels
);
if
(
!
s
->
nb_null_samples
)
return
AVERROR
(
ENOMEM
);
...
...
tests/ref/fate/filter-metadata-silencedetect
View file @
56b2731a
...
...
@@ -12,12 +12,12 @@ pkt_pts=3200
pkt_pts=3520
pkt_pts=3840
pkt_pts=4160
pkt_pts=4480|tag:lavfi.silence_start=
-0.02
pkt_pts=4480|tag:lavfi.silence_start=
0
pkt_pts=4800
pkt_pts=5120
pkt_pts=5440
pkt_pts=5760
pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.
4
pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.
38
pkt_pts=6400
pkt_pts=6720
pkt_pts=7040
...
...
@@ -72,7 +72,7 @@ pkt_pts=22400
pkt_pts=22720
pkt_pts=23040
pkt_pts=23360
pkt_pts=23680|tag:lavfi.silence_start=1.18
pkt_pts=23680|tag:lavfi.silence_start=1.18
756
pkt_pts=24000
pkt_pts=24320
pkt_pts=24640
...
...
@@ -97,7 +97,7 @@ pkt_pts=30400
pkt_pts=30720
pkt_pts=31040
pkt_pts=31360
pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.8
pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.
79243
8
pkt_pts=32000
pkt_pts=32320
pkt_pts=32640
...
...
@@ -160,7 +160,7 @@ pkt_pts=50560
pkt_pts=50880
pkt_pts=51200
pkt_pts=51520
pkt_pts=51840|tag:lavfi.silence_start=2.94
pkt_pts=51840|tag:lavfi.silence_start=2.94
5
pkt_pts=52160
pkt_pts=52480
pkt_pts=52800
...
...
@@ -196,7 +196,7 @@ pkt_pts=62080
pkt_pts=62400
pkt_pts=62720
pkt_pts=63040
pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.0
2
pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.0
15
pkt_pts=63680
pkt_pts=64000
pkt_pts=64320
...
...
@@ -250,7 +250,7 @@ pkt_pts=79360
pkt_pts=79680
pkt_pts=80000
pkt_pts=80320
pkt_pts=80640|tag:lavfi.silence_start=4.7
4
pkt_pts=80640|tag:lavfi.silence_start=4.7
5662
pkt_pts=80960
pkt_pts=81280
pkt_pts=81600
...
...
@@ -270,7 +270,7 @@ pkt_pts=85760
pkt_pts=86080
pkt_pts=86400
pkt_pts=86720
pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.
7
pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.
683375
pkt_pts=87360
pkt_pts=87680
pkt_pts=88000
...
...
@@ -326,7 +326,7 @@ pkt_pts=103680
pkt_pts=104000
pkt_pts=104320
pkt_pts=104640
pkt_pts=104960|tag:lavfi.silence_start=6.2
6
pkt_pts=104960|tag:lavfi.silence_start=6.2
7319
pkt_pts=105280
pkt_pts=105600
pkt_pts=105920
...
...
@@ -362,7 +362,7 @@ pkt_pts=115200
pkt_pts=115520
pkt_pts=115840
pkt_pts=116160
pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.0
2
pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.0
0681
pkt_pts=116800
pkt_pts=117120
pkt_pts=117440
...
...
@@ -425,7 +425,7 @@ pkt_pts=135360
pkt_pts=135680
pkt_pts=136000
pkt_pts=136320
pkt_pts=136640|tag:lavfi.silence_start=8.2
4
pkt_pts=136640|tag:lavfi.silence_start=8.2
5106
pkt_pts=136960
pkt_pts=137280
pkt_pts=137600
...
...
@@ -452,7 +452,7 @@ pkt_pts=144000
pkt_pts=144320
pkt_pts=144640
pkt_pts=144960
pkt_pts=145280|tag:lavfi.silence_end=9.08|tag:lavfi.silence_duration=0.8
4
pkt_pts=145280|tag:lavfi.silence_end=9.08|tag:lavfi.silence_duration=0.8
28937
pkt_pts=145600
pkt_pts=145920
pkt_pts=146240
...
...
@@ -504,7 +504,7 @@ pkt_pts=160640
pkt_pts=160960
pkt_pts=161280
pkt_pts=161600
pkt_pts=161920|tag:lavfi.silence_start=9.8
2
pkt_pts=161920|tag:lavfi.silence_start=9.8
3881
pkt_pts=162240
pkt_pts=162560
pkt_pts=162880
...
...
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