[FFmpeg-devel] acrossfade filter crossfading before first input is exhausted

Submitted by Mark Niebur on Oct. 30, 2019, 9:58 p.m.

Details

Message ID D1BD7933-15F3-4EF9-BB3F-FCE453D72D68@thuuz.com
State New
Headers show

Commit Message

Mark Niebur Oct. 30, 2019, 9:58 p.m.
Hello,
I have been trying to use acrossfade but have been experiencing that the audio in the resulting output is totally jumbled.  From stepping through the code, it appears that acrossfade is starting the crossfade before the first input is exhausted.  I'm not sure why this happens from ffmpeg's point of view; I'm guessing it's from poor disk performance in docker.  I have found that the following patch fixes this issue:


Could you please merge this patch or merge a similar fix?

Thanks,
Mark Niebur

Comments

Paul B Mahol Oct. 31, 2019, 10:02 a.m.
Done,

On 10/30/19, Mark Niebur <mniebur@thuuz.com> wrote:
> Hello,
> I have been trying to use acrossfade but have been experiencing that the
> audio in the resulting output is totally jumbled.  From stepping through the
> code, it appears that acrossfade is starting the crossfade before the first
> input is exhausted.  I'm not sure why this happens from ffmpeg's point of
> view; I'm guessing it's from poor disk performance in docker.  I have found
> that the following patch fixes this issue:
>
> diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
> index 23608fb..91a454b 100644
> --- a/libavfilter/af_afade.c
> +++ b/libavfilter/af_afade.c
> @@ -485,7 +485,8 @@ static int activate(AVFilterContext *ctx)
>              (AVRational){ 1, outlink->sample_rate }, outlink->time_base);
>          return ff_filter_frame(outlink, in);
>      } else if (ff_inlink_queued_samples(ctx->inputs[0]) >= s->nb_samples &&
> -               ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples) {
> +               ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples &&
> +               s->cf0_eof) {
>          if (s->overlap) {
>              out = ff_get_audio_buffer(outlink, s->nb_samples);
>              if (!out)
>
> Could you please merge this patch or merge a similar fix?
>
> Thanks,
> Mark Niebur
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
index 23608fb..91a454b 100644
--- a/libavfilter/af_afade.c
+++ b/libavfilter/af_afade.c
@@ -485,7 +485,8 @@  static int activate(AVFilterContext *ctx)
             (AVRational){ 1, outlink->sample_rate }, outlink->time_base);
         return ff_filter_frame(outlink, in);
     } else if (ff_inlink_queued_samples(ctx->inputs[0]) >= s->nb_samples &&
-               ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples) {
+               ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples &&
+               s->cf0_eof) {
         if (s->overlap) {
             out = ff_get_audio_buffer(outlink, s->nb_samples);
             if (!out)