Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
6c26fe8b
Commit
6c26fe8b
authored
13 years ago
by
Stefano Sabatini
Browse files
Options
Downloads
Patches
Plain Diff
aevalsrc: add duration option
parent
ba8410cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/filters.texi
+10
-0
10 additions, 0 deletions
doc/filters.texi
libavfilter/asrc_aevalsrc.c
+22
-1
22 additions, 1 deletion
libavfilter/asrc_aevalsrc.c
libavfilter/avfilter.h
+1
-1
1 addition, 1 deletion
libavfilter/avfilter.h
with
33 additions
and
2 deletions
doc/filters.texi
+
10
−
0
View file @
6c26fe8b
...
@@ -405,6 +405,16 @@ The description of the accepted options follows.
...
@@ -405,6 +405,16 @@ The description of the accepted options follows.
@table @option
@table @option
@item duration, d
Set the minimum duration of the sourced audio. See the function
@code{av_parse_time()} for the accepted format.
Note that the resulting duration may be greater than the specified
duration, as the generated audio is always cut at the end of a
complete frame.
If not specified, or the expressed duration is negative, the audio is
supposed to be generated forever.
@item nb_samples, n
@item nb_samples, n
Set the number of samples per channel per each output frame,
Set the number of samples per channel per each output frame,
default to 1024.
default to 1024.
...
...
This diff is collapsed.
Click to expand it.
libavfilter/asrc_aevalsrc.c
+
22
−
1
View file @
6c26fe8b
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include
"libavutil/avstring.h"
#include
"libavutil/avstring.h"
#include
"libavutil/eval.h"
#include
"libavutil/eval.h"
#include
"libavutil/opt.h"
#include
"libavutil/opt.h"
#include
"libavutil/parseutils.h"
#include
"avfilter.h"
#include
"avfilter.h"
#include
"internal.h"
#include
"internal.h"
...
@@ -55,6 +56,8 @@ typedef struct {
...
@@ -55,6 +56,8 @@ typedef struct {
AVExpr
*
expr
[
8
];
AVExpr
*
expr
[
8
];
char
*
expr_str
[
8
];
char
*
expr_str
[
8
];
int
nb_samples
;
///< number of samples per requested frame
int
nb_samples
;
///< number of samples per requested frame
char
*
duration_str
;
///< total duration of the generated audio
double
duration
;
uint64_t
n
;
uint64_t
n
;
double
var_values
[
VAR_VARS_NB
];
double
var_values
[
VAR_VARS_NB
];
}
EvalContext
;
}
EvalContext
;
...
@@ -66,6 +69,8 @@ static const AVOption eval_options[]= {
...
@@ -66,6 +69,8 @@ static const AVOption eval_options[]= {
{
"n"
,
"set the number of samples per requested frame"
,
OFFSET
(
nb_samples
),
AV_OPT_TYPE_INT
,
{.
dbl
=
1024
},
0
,
INT_MAX
},
{
"n"
,
"set the number of samples per requested frame"
,
OFFSET
(
nb_samples
),
AV_OPT_TYPE_INT
,
{.
dbl
=
1024
},
0
,
INT_MAX
},
{
"sample_rate"
,
"set the sample rate"
,
OFFSET
(
sample_rate_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
"44100"
},
CHAR_MIN
,
CHAR_MAX
},
{
"sample_rate"
,
"set the sample rate"
,
OFFSET
(
sample_rate_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
"44100"
},
CHAR_MIN
,
CHAR_MAX
},
{
"s"
,
"set the sample rate"
,
OFFSET
(
sample_rate_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
"44100"
},
CHAR_MIN
,
CHAR_MAX
},
{
"s"
,
"set the sample rate"
,
OFFSET
(
sample_rate_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
"44100"
},
CHAR_MIN
,
CHAR_MAX
},
{
"duration"
,
"set audio duration"
,
OFFSET
(
duration_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
},
{
"d"
,
"set audio duration"
,
OFFSET
(
duration_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
},
{
NULL
},
{
NULL
},
};
};
...
@@ -127,6 +132,16 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque)
...
@@ -127,6 +132,16 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque)
if
((
ret
=
ff_parse_sample_rate
(
&
eval
->
sample_rate
,
eval
->
sample_rate_str
,
ctx
)))
if
((
ret
=
ff_parse_sample_rate
(
&
eval
->
sample_rate
,
eval
->
sample_rate_str
,
ctx
)))
goto
end
;
goto
end
;
eval
->
duration
=
-
1
;
if
(
eval
->
duration_str
)
{
int64_t
us
=
-
1
;
if
((
ret
=
av_parse_time
(
&
us
,
eval
->
duration_str
,
1
))
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid duration: '%s'
\n
"
,
eval
->
duration_str
);
goto
end
;
}
eval
->
duration
=
(
double
)
us
/
1000000
;
}
eval
->
n
=
0
;
eval
->
n
=
0
;
end:
end:
...
@@ -143,6 +158,7 @@ static void uninit(AVFilterContext *ctx)
...
@@ -143,6 +158,7 @@ static void uninit(AVFilterContext *ctx)
av_expr_free
(
eval
->
expr
[
i
]);
av_expr_free
(
eval
->
expr
[
i
]);
eval
->
expr
[
i
]
=
NULL
;
eval
->
expr
[
i
]
=
NULL
;
}
}
av_freep
(
&
eval
->
duration_str
);
av_freep
(
&
eval
->
sample_rate_str
);
av_freep
(
&
eval
->
sample_rate_str
);
}
}
...
@@ -159,7 +175,8 @@ static int config_props(AVFilterLink *outlink)
...
@@ -159,7 +175,8 @@ static int config_props(AVFilterLink *outlink)
av_get_channel_layout_string
(
buf
,
sizeof
(
buf
),
0
,
eval
->
chlayout
);
av_get_channel_layout_string
(
buf
,
sizeof
(
buf
),
0
,
eval
->
chlayout
);
av_log
(
outlink
->
src
,
AV_LOG_INFO
,
av_log
(
outlink
->
src
,
AV_LOG_INFO
,
"sample_rate:%d chlayout:%s
\n
"
,
eval
->
sample_rate
,
buf
);
"sample_rate:%d chlayout:%s duration:%f
\n
"
,
eval
->
sample_rate
,
buf
,
eval
->
duration
);
return
0
;
return
0
;
}
}
...
@@ -183,6 +200,10 @@ static int request_frame(AVFilterLink *outlink)
...
@@ -183,6 +200,10 @@ static int request_frame(AVFilterLink *outlink)
EvalContext
*
eval
=
outlink
->
src
->
priv
;
EvalContext
*
eval
=
outlink
->
src
->
priv
;
AVFilterBufferRef
*
samplesref
;
AVFilterBufferRef
*
samplesref
;
int
i
,
j
;
int
i
,
j
;
double
t
=
eval
->
var_values
[
VAR_N
]
*
(
double
)
1
/
eval
->
sample_rate
;
if
(
eval
->
duration
>=
0
&&
t
>
eval
->
duration
)
return
AVERROR_EOF
;
samplesref
=
avfilter_get_audio_buffer
(
outlink
,
AV_PERM_WRITE
,
eval
->
nb_samples
);
samplesref
=
avfilter_get_audio_buffer
(
outlink
,
AV_PERM_WRITE
,
eval
->
nb_samples
);
...
...
This diff is collapsed.
Click to expand it.
libavfilter/avfilter.h
+
1
−
1
View file @
6c26fe8b
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 50
#define LIBAVFILTER_VERSION_MINOR 50
#define LIBAVFILTER_VERSION_MICRO
0
#define LIBAVFILTER_VERSION_MICRO
1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment