[FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers

Bodecs Bela bodecsb at vivanet.hu
Fri Sep 25 13:28:11 CEST 2015


Hi All,

currently, select option of tee pseudo muxer may contain only one stream 
specifier. Sometimes I need to use more than one stream specifier.
So I made the following patch. It makes possible to put multiple stream 
specifier into select option separated by comma.
eg. select=\'a:0,v\'
(I choose the comma character as separator because it is similar to 
tee's bsf option separator. bsf option allows multiple value separated 
by comma)

Please consider that put this patch into the official ffmpeg source tree.




thank you,

Bela Bodecs


p.s.:the documentation/web also should alter by this, but I do not know 
where to send this:

select

    Select the streams that should be mapped to the slave output,
    specified by a stream specifier. If not specified, this defaults to
    all the input streams.

+++
      You may use multiple stream specifiers separated by commas (,)  
eg.: a:0,v


Patch description:


  diff -u tee.c.orig tee.c
--- tee.c.orig  2015-07-09 22:22:27.000000000 +0200
+++ tee.c       2015-09-25 13:15:15.763273903 +0200
@@ -47,6 +47,7 @@
  static const char *const slave_opt_close = "]";
  static const char *const slave_opt_delim = ":]"; /* must have the 
close too */
  static const char *const slave_bsfs_spec_sep = "/";
+static const char *const slave_select_sep = ",";

  static const AVClass tee_muxer_class = {
      .class_name = "Tee muxer",
@@ -142,7 +143,9 @@
      AVFormatContext *avf2 = NULL;
      AVStream *st, *st2;
      int stream_count;
-
+    int fullret;
+    char *subselect = NULL, *next_subselect = NULL, *first_subselect;
+
      if ((ret = parse_slave_options(avf, slave, &options, &filename)) < 0)
          return ret;

@@ -172,15 +175,26 @@
      for (i = 0; i < avf->nb_streams; i++) {
          st = avf->streams[i];
          if (select) {
-            ret = avformat_match_stream_specifier(avf, avf->streams[i], 
select);
-            if (ret < 0) {
-                av_log(avf, AV_LOG_ERROR,
-                       "Invalid stream specifier '%s' for output '%s'\n",
-                       select, slave);
-                goto end;
-            }
+            fullret = 0;
+            first_subselect = select;
+            next_subselect = NULL;
+            while (subselect = strtok_r(first_subselect, 
slave_select_sep, &next_subselect)) {
+                first_subselect = NULL;
+
+                ret = avformat_match_stream_specifier(avf, 
avf->streams[i], subselect);
+                if (ret < 0) {
+                    av_log(avf, AV_LOG_ERROR,
+                        "Invalid stream specifier '%s' for output '%s'\n",
+                        subselect, slave);
+                    goto end;
+                }
+                if (ret != 0) {
+                    fullret = 1; // match
+                    break;
+                }

-            if (ret == 0) { /* no match */
+            }
+            if (fullret == 0) { /* no match */
                  tee_slave->stream_map[i] = -1;
                  continue;
              }



More information about the ffmpeg-devel mailing list