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

Bodecs Bela bodecsb at vivanet.hu
Tue Sep 29 11:54:47 CEST 2015


ping

2015.09.25. 13:28 keltezéssel, Bodecs Bela írta:
> 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 values 
> 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
>

-------------- next part --------------
From 45330b5bdf77f0b424d2631bddfc61bfdcc5901d Mon Sep 17 00:00:00 2001
From: Bela Bodecs <bodecsb at vivanet.hu>
Date: Tue, 29 Sep 2015 11:04:05 +0200
Subject: [PATCH]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

---
 libavformat/tee.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)


--------------1.8.3.1
Content-Type: text/x-patch; name="0001-select-by-bb.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-select-by-bb.patch"

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--




More information about the ffmpeg-devel mailing list