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
9076a6a9
Commit
9076a6a9
authored
Mar 13, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/filtering_audio: update to new API
In particular, fix crash.
parent
f0da370a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
filtering_audio.c
doc/examples/filtering_audio.c
+12
-14
No files found.
doc/examples/filtering_audio.c
View file @
9076a6a9
...
...
@@ -150,11 +150,10 @@ static int init_filters(const char *filters_descr)
return
0
;
}
static
void
print_
samplesref
(
AVFilterBufferRef
*
samplesref
)
static
void
print_
frame
(
AVFrame
*
frame
)
{
const
AVFilterBufferRefAudioProps
*
props
=
samplesref
->
audio
;
const
int
n
=
props
->
nb_samples
*
av_get_channel_layout_nb_channels
(
props
->
channel_layout
);
const
uint16_t
*
p
=
(
uint16_t
*
)
samplesref
->
data
[
0
];
const
int
n
=
frame
->
nb_samples
*
av_get_channel_layout_nb_channels
(
av_frame_get_channel_layout
(
frame
));
const
uint16_t
*
p
=
(
uint16_t
*
)
frame
->
data
[
0
];
const
uint16_t
*
p_end
=
p
+
n
;
while
(
p
<
p_end
)
{
...
...
@@ -169,10 +168,11 @@ int main(int argc, char **argv)
{
int
ret
;
AVPacket
packet
;
AVFrame
*
frame
=
avcodec_alloc_frame
();
AVFrame
*
frame
=
av_frame_alloc
();
AVFrame
*
filt_frame
=
av_frame_alloc
();
int
got_frame
;
if
(
!
frame
)
{
if
(
!
frame
||
!
filt_frame
)
{
perror
(
"Could not allocate frame"
);
exit
(
1
);
}
...
...
@@ -192,7 +192,6 @@ int main(int argc, char **argv)
/* read all packets */
while
(
1
)
{
AVFilterBufferRef
*
samplesref
;
if
((
ret
=
av_read_frame
(
fmt_ctx
,
&
packet
))
<
0
)
break
;
...
...
@@ -207,22 +206,20 @@ int main(int argc, char **argv)
if
(
got_frame
)
{
/* push the audio data from decoded frame into the filtergraph */
if
(
av_buffersrc_add_frame
(
buffersrc_ctx
,
frame
)
<
0
)
{
if
(
av_buffersrc_add_frame
_flags
(
buffersrc_ctx
,
frame
,
AV_BUFFERSRC_FLAG_KEEP_REF
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while feeding the audio filtergraph
\n
"
);
break
;
}
/* pull filtered audio from the filtergraph */
while
(
1
)
{
ret
=
av_buffersink_get_
buffer_ref
(
buffersink_ctx
,
&
samplesref
,
0
);
ret
=
av_buffersink_get_
frame
(
buffersink_ctx
,
filt_frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
break
;
if
(
ret
<
0
)
goto
end
;
if
(
samplesref
)
{
print_samplesref
(
samplesref
);
avfilter_unref_bufferp
(
&
samplesref
);
}
print_frame
(
filt_frame
);
av_frame_unref
(
filt_frame
);
}
}
}
...
...
@@ -233,7 +230,8 @@ end:
if
(
dec_ctx
)
avcodec_close
(
dec_ctx
);
avformat_close_input
(
&
fmt_ctx
);
av_freep
(
&
frame
);
av_frame_free
(
&
frame
);
av_frame_free
(
&
filt_frame
);
if
(
ret
<
0
&&
ret
!=
AVERROR_EOF
)
{
char
buf
[
1024
];
...
...
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