[FFmpeg-devel] avfilter/astreamslect: fixing activating in some cases

Submitted by Bodecs Bela on March 14, 2018, 6:24 p.m.

Details

Message ID e383a1e7-90f4-cf8e-2181-bf9ee896a274@vivanet.hu
State New
Headers show

Commit Message

Bodecs Bela March 14, 2018, 6:24 p.m.
Dear All,

In case of some content, astreamselect filter remains in non active
state.

please review this pacth. I am not sure this is the right fix of this.

thank you, in advance!


Bela Bodecs
From acd81c80b8b5b33b03e99adb3bad04bc291e4218 Mon Sep 17 00:00:00 2001
From: Bela Bodecs <bodecsb@vivanet.hu>
Date: Wed, 14 Mar 2018 19:22:03 +0100
Subject: [PATCH] avfilter/f_astreamselect: fixing activating in some cases

In case of some content, astreamselect filter remains in non active
state.

Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu>
---
 libavfilter/f_streamselect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Nicolas George March 14, 2018, 7:29 p.m.
Bodecs Bela (2018-03-14):
> In case of some content, astreamselect filter remains in non active
> state.
> 
> please review this pacth. I am not sure this is the right fix of this.

I am not sure either. framesync was not designed for audio. I would like
to investigate: can you share the failing case?

Regards,
Bodecs Bela March 17, 2018, 10:09 a.m.
2018.03.14. 20:29 keltezéssel, Nicolas George írta:
> Bodecs Bela (2018-03-14):
>> In case of some content, astreamselect filter remains in non active
>> state.
>>
>> please review this pacth. I am not sure this is the right fix of this.
> I am not sure either. framesync was not designed for audio. I would like
> to investigate: can you share the failing case?
>
> Regards,
>
>

ffmpeg -loglevel info -y \
      -re -i a.mp4 \
      -re -i b.mp4 \
      -filter_complex "[0:a][1:a] astreamselect=inputs=2:map=1 [out_a]"   \
      -map "[out_a]"  -vn   \
      -f framemd5 -

a.mp4 and b.mp4 are available on these direct links:
http://download.songo.hu/a.mp4
http://download.songo.hu/b.mp4
(they are 500k each)

with my patch it works good.

bb

>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Nicolas George March 18, 2018, 12:57 p.m.
Bodecs Bela (2018-03-17):
> with my patch it works good.

Thanks for the details. After more careful examination, I confirm my
first impression: calling ff_filter_set_ready() from the framesync
callback would be wrong. But this filter already misuses internal APIs
(for example re-calling avfilter_config_links() after init) and contains
several easily spotted bugs.

Regards,
Carl Eugen Hoyos March 18, 2018, 3:04 p.m.
2018-03-18 13:57 GMT+01:00, Nicolas George <george@nsup.org>:
> Bodecs Bela (2018-03-17):
>> with my patch it works good.
>
> Thanks for the details. After more careful examination, I confirm my
> first impression: calling ff_filter_set_ready() from the framesync
> callback would be wrong. But this filter already misuses internal APIs
> (for example re-calling avfilter_config_links() after init) and contains
> several easily spotted bugs.

Not knowing what this is all about, I believe you should elaborate a
little.

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c
index 923deb1..2aef3f4 100644
--- a/libavfilter/f_streamselect.c
+++ b/libavfilter/f_streamselect.c
@@ -25,6 +25,7 @@ 
 #include "framesync.h"
 #include "internal.h"
 #include "video.h"
+#include "filters.h"
 
 typedef struct StreamSelectContext {
     const AVClass *class;
@@ -66,8 +67,10 @@  static int process_frame(FFFrameSync *fs)
                 AVFrame *out;
 
                 if (s->is_audio && s->last_pts[j] == in[j]->pts &&
-                    ctx->outputs[i]->frame_count_in > 0)
+                    ctx->outputs[i]->frame_count_in > 0) {
+                    ff_filter_set_ready(ctx->outputs[i]->src, 200);
                     continue;
+                }
                 out = av_frame_clone(in[j]);
                 if (!out)
                     return AVERROR(ENOMEM);