I have made it as you wrote. I replaced the strtok_r function with the supported one.
I also have included the modified texi file.
I have enclosed the git patch file.

bb

2015.09.30. 15:53 keltezéssel, Nicolas George írta:
Sorry for the delay.

Bodecs Bela:
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)
Thanks for the patch, the feature looks useful indeed.

Please consider that put this patch into the official ffmpeg source tree.
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.
It would be best to update the documentation in the same patch. The current
documentation is in doc/muxers.texi (can be found with
`git grep "Select the streams that should be mapped"`).

Patch description:
Please use git send-email or git format-patch, so that the patch includes
author information and commit message. Also, the patch has been mangled by
your mail user agent, it can not be applied as is.

  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)) {
strtok_r() is not portable enough, but libavutil provides av_strtok().

+                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;
              }
Regards,



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

From ea29f053a8869373af54952b4935a9e11727d6ed Mon Sep 17 00:00:00 2001
From: Bela Bodecs <bode...@vivanet.hu>
Date: Thu, 1 Oct 2015 10:17:36 +0200
Subject: [PATCH 1/1] select attribute of tee pseudo demuxer may contain
 multiple stream specifiers
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.8.3.1"

This is a multi-part message in MIME format.
--------------1.8.3.1
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 doc/muxers.texi   |  3 ++-
 libavformat/tee.c | 32 +++++++++++++++++++++++---------
 2 files changed, 25 insertions(+), 10 deletions(-)


--------------1.8.3.1
Content-Type: text/x-patch; 
name="0001-select-attribute-of-tee-pseudo-demuxer-may-contain-m.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; 
filename="0001-select-attribute-of-tee-pseudo-demuxer-may-contain-m.patch"

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d75d7de..e8a2467 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1224,7 +1224,8 @@ Several bitstream filters can be specified, separated by 
",".
 @item 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.
+all the input streams. You may use multiple stream specifiers 
+separated by commas (,)  eg.: a:0,v
 @end table
 
 @subsection Examples
diff --git a/libavformat/tee.c b/libavformat/tee.c
index e3d466a..cdbbf86 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -47,6 +47,7 @@ static const char *const slave_opt_open  = "[";
 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 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
     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 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
     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;
             }

--------------1.8.3.1--


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to