[FFmpeg-devel] round-robin like scheduling for multichannel inputs. Important in case of capture devices. Else the first channel is preferred always.

Submitted by Roman Sidler on Nov. 6, 2018, 12:15 p.m.

Details

Message ID 20181106121510.13484-1-roman.sidler@sidler-se.net
State New
Headers show

Commit Message

Roman Sidler Nov. 6, 2018, 12:15 p.m.
---
 fftools/ffmpeg.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos Nov. 6, 2018, 9:52 p.m.
2018-11-06 13:15 GMT+01:00, Roman Sidler <sidse007@gmail.com>:
> ---
>  fftools/ffmpeg.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index da4259a9a8..fa54421d73 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -3869,12 +3869,14 @@ static int need_output(void)
>   */
>  static OutputStream *choose_output(void)
>  {
> -    int i;
> +    int i,_i;

I cannot comment on the change but please do not
use variable names starting with "_".

Carl Eugen
Michael Niedermayer Nov. 7, 2018, 1:08 p.m.
On Tue, Nov 06, 2018 at 01:15:10PM +0100, Roman Sidler wrote:
> ---
>  fftools/ffmpeg.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index da4259a9a8..fa54421d73 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c

breaks fate and looks hackish

[...]

Patch hide | download patch | download mbox

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index da4259a9a8..fa54421d73 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3869,12 +3869,14 @@  static int need_output(void)
  */
 static OutputStream *choose_output(void)
 {
-    int i;
+    int i,_i;
+    static int last_i;
     int64_t opts_min = INT64_MAX;
     OutputStream *ost_min = NULL;
 
     for (i = 0; i < nb_output_streams; i++) {
-        OutputStream *ost = output_streams[i];
+        _i = (last_i + 1 + i) %nb_output_streams;
+        OutputStream *ost = output_streams[_i];
         int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN :
                        av_rescale_q(ost->st->cur_dts, ost->st->time_base,
                                     AV_TIME_BASE_Q);
@@ -3889,6 +3891,8 @@  static OutputStream *choose_output(void)
             ost_min  = ost->unavailable ? NULL : ost;
         }
     }
+    if (ost_min)
+        last_i = ost_min->file_index;
     return ost_min;
 }