[Libav-user] AVFilter abuffer Buffering limit reached
Bryan Stewart
bstewart at ais-sim.com
Thu Apr 5 16:36:32 CEST 2012
I am trying to merge two audio streams with different sample rates in to
a single s16 stereo stream:
-lavfi "[I1] aresample=44100, ashowinfo, aconvert=s16:stereo [L1];
[I2] aresample=44100, ashowinfo, aconvert=s16:stereo [L2];
[L1] [l2] amerge, aconvert=s16:stereo [out]"
The input audio files:
[I1] <= file.mpg (48000HZ, stereo, s16, 224 kb/s)
[I2] <= file.avi (44100HZ, stereo, s16, 1411 kb/s)
[I1] and [I2] are AVFilterContext *, and are added to an AVFilter graph:
AVFilterContext *I1Ctx;
AVFilterContext *I2Ctx;
AVFilterContext *OCtx;
AVFilterBufferRef *bufref;
AVFilterGraph *graph;
...
graph = avfilter_graph_alloc ();
int result (0);
char args[255];
...
result =
avfilter_graph_create_filter (
I1Ctx, avfilter_get_by_name ("abuffer"),
"I1", args, NULL, graph);
result =
avfilter_graph_create_filter (
I2Ctx, avfilter_get_by_name ("abuffer"),
"I2", args, NULL, graph);
result =
avfilter_graph_create_filter (
OCtx, avfilter_get_by_name ("abuffersink"),
"out", NULL, abufferSinkParams, graph);
...
Each frame, I add decoded data from the audio files in to the buffer
sources I1Ctx and I2Ctx, and then retrieve the resulting data from the
filter graph and encode that result.
...
result =
av_asrc_buffer_add_buffer (
I1Ctx, decodedFrame1->data[0], frame1Size, ...);
...
result =
av_asrc_buffer_add_buffer (
I2Ctx, decodedFrame2->data[0], frame2Size, ...);
...
if (av_buffersink_get_buffer_ref (OCtx, bufref) {
AVFrame frame;
myFillFrameFromBufferRef (frame, bufref);
myEncodeAudioFrame (frame);
}
Here is the issue, at certain frames, the I1 abuffer_source does not
output data from its fifo, eventhough a valid bufref is returned in that
frame:
[ashowinfo @ 0370BD60] n:0 pts:95038 pts_time:2.15506 pos:0 fmt:s16
chlayout:ste
reo nb_samples:1049 rate:44100 planar:0 checksum:00000000
plane_checksum[0000000
0]
[ashowinfo @ 0370BEC0] n:0 pts:11264 pts_time:0.25542 pos:0 fmt:s16
chlayout:ste
reo nb_samples:1024 rate:44100 planar:0 checksum:A373FABB
plane_checksum[A373FAB
B]
- bufref pts 95038
...- 1.3.3, 47528
...frame packet: dts|pts|duration: 36 | 36 | 1
- avpkt start size: 153600, index: 0
- enqueue capture video packet
...frame packet: dts|pts|duration: 105603 | 105603 | 2160
- avpkt start size: 672, index: 1
- transcode current media audio packet
- decode capture audio packet, 12288 | 12288
- insert capture audio frame, 1
[ashowinfo @ 0370BEC0] n:1 pts:12288 pts_time:0.278639 pos:0 fmt:s16
chlayout:st
ereo nb_samples:1024 rate:44100 planar:0 checksum:95304463
plane_checksum[953044
63]
- bufref pts 95038
...- 1.3.3, 40184
...frame packet: dts|pts|duration: 37 | 37 | 1
- avpkt start size: 153600, index: 0
- enqueue capture video packet
...frame packet: dts|pts|duration: 107763 | 107763 | 2160
- avpkt start size: 672, index: 1
- transcode current media audio packet
- decode capture audio packet, 13312 | 13312
- insert capture audio frame, 1
[ashowinfo @ 0370BD60] n:1 pts:97023 pts_time:2.20007 pos:0 fmt:s16
chlayout:ste
reo nb_samples:1058 rate:44100 planar:0 checksum:00000000
plane_checksum[0000000
0]
[ashowinfo @ 0370BEC0] n:2 pts:13312 pts_time:0.301859 pos:0 fmt:s16
chlayout:st
ereo nb_samples:1024 rate:44100 planar:0 checksum:A0E3C8B0
plane_checksum[A0E3C8
B0]
Since I continue to place data into the buffer sources at the same rate,
I will eventually get the I1Ctx buffer source to overflow its fifo and
the following error is returned continuously:
[abuffer @ 0106BBC0] Buffering limit reached. Please consume some
available frames before adding new ones.
Why does the abuffer_src not return data from its fifo when the two
input sources have the same sample rate for the amerge?
--
#-----------------------------------------------------------------#
# Bryan C. Stewart Email: bstewart at ais-sim.com #
# Web: www.ais-sim.com #
# Advanced Interactive Systems, Inc. Phone: (831)655-0440 #
# 8 Harris Ct, Suite B5, Fax: (831)655-0885 #
# Monterey, CA 93940 #
#-----------------------------------------------------------------#
*
*
CONFIDENTIALITY NOTICE
----------------------
This message, together with any attachments, may be legally
privileged and is confidential information intended only for
the use of the individual or entity to which it is addressed.
It is exempt from disclosure under applicable law including
court orders. If you are not the intended recipient, you are
hereby notified that any use, dissemination, distribution or
copy of this message, or any attachment, is strictly
prohibited. If you have received this message in error, please
notify the original sender and delete this message, along with
any attachments, from your computer.
In addition, Data contained in this email may be subject to the
International Traffic in Arms Regulation (ITAR) or the Export
Administration Regulation (EAR) of 1979. Regulated data may not
be exported, released, or disclosed to foreign nationals inside
or outside the United States without obtaining the prior
written approval of Advanced Interactive Systems, Inc. and
licenses as required by the U.S. Department of State.
More information about the Libav-user
mailing list