Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
Le nonidi 19 vendémiaire, an CCXXIV, Bodecs Bela a écrit : > I have altered the code as you wrote. Pushed, thanks. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
2015.10.10. 19:33 keltezéssel, Nicolas George írta: L'octidi 18 vendémiaire, an CCXXIV, Bodecs Bela a écrit : I have altered the code to work correctly in situations with multiple streams. I have also tested it with your command. Thanks, it looks almost good for apply. Your other patches were made with git format-patch, so that is ok; do not forget the "signed-off-by" tag (--signoff option), just to be on the safe side legally. --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1272,7 +1272,8 @@ @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 (@code{,}) e.g.: @code{a:0,v} @end table @subsection Examples diff --git a/libavformat/tee.c b/libavformat/tee.c index c619eae..324aa43 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -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,6 +143,8 @@ AVFormatContext *avf2 = NULL; AVStream *st, *st2; int stream_count; +int fullret; +char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, *tmp_select = NULL; if ((ret = parse_slave_options(avf, slave, , )) < 0) return ret; @@ -172,15 +175,33 @@ 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); +tmp_select = av_strdup(select); // av_strtok is destructive so we regenerate it in each loop +if (!tmp_select) { +av_log(avf, AV_LOG_ERROR, "Unexpected internal memory allocation error occured during string duplication\n"); goto end; ret needs to be set to some value before jumping to end. Setting it to AVERROR(ENOMEM) makes the error message unnecessary; the code usually does not print a message for OOM. } +fullret = 0; +first_subselect = tmp_select; +next_subselect = NULL; +while (subselect = av_strtok(first_subselect, slave_select_sep, _subselect)) { +first_subselect = NULL; -if (ret == 0) { /* no match */ +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); +av_free(tmp_select); +goto end; +} +if (ret != 0) { +fullret = 1; // match +break; +} +} +av_free(tmp_select); This code is safe. For extra robustness, it could ensure that tmp_select is NULL when not used (initing to NULL and using av_freep()), and move the free in the error case to the end clause. But I do not insist on that change. + +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 I have altered the code as you wrote. best regards, Bela Bodecs >From 25f36f26f2d65e3bca7711a9cfb2808e381cd093 Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Sat, 10 Oct 2015 21:29:12 +0200 Subject: [PATCH 3/3] select attribute of tee pseudo demuxer may contain multiple stream specifiers 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) Signed-off-by: Bela Bodecs --- doc/muxers.texi | 3 ++- libavformat/tee.c | 33 +++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 91d131f..610ff58 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1272,7 +1272,8 @@ Several bitstream filters can be specified,
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
L'octidi 18 vendémiaire, an CCXXIV, Bodecs Bela a écrit : > I have altered the code to work correctly in situations with multiple > streams. I have also tested it with your command. Thanks, it looks almost good for apply. Your other patches were made with git format-patch, so that is ok; do not forget the "signed-off-by" tag (--signoff option), just to be on the safe side legally. > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -1272,7 +1272,8 @@ > @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 (@code{,}) e.g.: @code{a:0,v} > @end table > > @subsection Examples > diff --git a/libavformat/tee.c b/libavformat/tee.c > index c619eae..324aa43 100644 > --- a/libavformat/tee.c > +++ b/libavformat/tee.c > @@ -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,6 +143,8 @@ > AVFormatContext *avf2 = NULL; > AVStream *st, *st2; > int stream_count; > +int fullret; > +char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, > *tmp_select = NULL; > > if ((ret = parse_slave_options(avf, slave, , )) < 0) > return ret; > @@ -172,15 +175,33 @@ > 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); > +tmp_select = av_strdup(select); // av_strtok is destructive so > we regenerate it in each loop > +if (!tmp_select) { > +av_log(avf, AV_LOG_ERROR, "Unexpected internal memory > allocation error occured during string duplication\n"); > goto end; ret needs to be set to some value before jumping to end. Setting it to AVERROR(ENOMEM) makes the error message unnecessary; the code usually does not print a message for OOM. > } > +fullret = 0; > +first_subselect = tmp_select; > +next_subselect = NULL; > +while (subselect = av_strtok(first_subselect, slave_select_sep, > _subselect)) { > +first_subselect = NULL; > > -if (ret == 0) { /* no match */ > +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); > +av_free(tmp_select); > +goto end; > +} > +if (ret != 0) { > +fullret = 1; // match > +break; > +} > +} > +av_free(tmp_select); This code is safe. For extra robustness, it could ensure that tmp_select is NULL when not used (initing to NULL and using av_freep()), and move the free in the error case to the end clause. But I do not insist on that change. > + > +if (fullret == 0) { /* no match */ > tee_slave->stream_map[i] = -1; > continue; > } Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
2015.10.04. 20:06 keltezéssel, Nicolas George írta: Le tridi 13 vendémiaire, an CCXXIV, Bodecs Bela a écrit : git format-patch -n -o /tmp/ --attach origin Thanks. Any particular reason to use --attach? It is not a big issue, just a matter of curiosity. Now, I used a different method to create the patch file. @@ -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 = av_strtok(first_subselect, slave_select_sep, _subselect)) { +first_subselect = NULL; You would be right unless I used first_subselect = NULL; right after the while statement, so the next round av_strtok will go further, because the first parameter will be null, not the same string and next_subselect will point the next start. Yes it is destructive, but we never use this string (select) again in this function. I suspect we are talking at cross-purpose here. The "first_subselect = NULL" you are talking about is in the while loop for av_strtok(), it is indeed the normal way of using av_strtok(). But I was talking about the surrounding for loop that goes over all the streams. I left the code quoted above for reference. For i=0, the code is valid, but as soon as i>=1, "first_subselect = select" will use a truncated string I swear, I have really tested it, I use it on my own in my production environment. I do not believe that you neglected to test it (nor that you are lying, of course!), I am just really surprised. Just to be sure, I just tested, adding a debug log just after "first_subselect = select", with the following command-line: ./ffmpeg_g -lavfi 'testsrc=r=5;testsrc=r=7;testsrc=r=11' \ -c:v rawvideo -f tee '[f=framecrc:select=0,1]-' I get the following output: select = '0,1' select = '0' Last message repeated 1 times [tee @ 0x36143e0] Input stream #1 is not mapped to any slave. [tee @ 0x36143e0] Input stream #2 is not mapped to any slave. The second "select =" line shows that it is working with a truncated line, and stream #1 should be mapped. Indeed, if I swap the specifiers: "1,0", it maps #0 and #1: #0 is matched first while the string is still intact, #1 is matched by the truncated string. Regards, ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel I have altered the code to work correctly in situations with multiple streams. I have also tested it with your command. best regards, bb diff --git a/doc/muxers.texi b/doc/muxers.texi index 91d131f..610ff58 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1272,7 +1272,8 @@ @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 (@code{,}) e.g.: @code{a:0,v} @end table @subsection Examples diff --git a/libavformat/tee.c b/libavformat/tee.c index c619eae..324aa43 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -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,6 +143,8 @@ AVFormatContext *avf2 = NULL; AVStream *st, *st2; int stream_count; +int fullret; +char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, *tmp_select = NULL; if ((ret = parse_slave_options(avf, slave, , )) < 0) return ret; @@ -172,15 +175,33 @@ 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); +tmp_select = av_strdup(select); // av_strtok is destructive so we regenerate it in each loop +if (!tmp_select) { +av_log(avf, AV_LOG_ERROR, "Unexpected internal memory allocation error occured during string duplication\n"); goto end; } +fullret = 0; +
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
Le decadi 10 vendémiaire, an CCXXIV, Bodecs Bela a écrit : > thank you for your feedback, I have altered the patch accordingly. I have > enclosed the updated patch file. Please remember not to top-post on these mailing-lists. See interleaved comments below. > From bcbd5e3e1a850fef1002d3a63c06fc52b2a3d169 Mon Sep 17 00:00:00 2001 > From: Bela Bodecs> Date: Thu, 1 Oct 2015 13:00:50 +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" This is rather strange. I wonder how you managed to produce this patch. > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index d75d7de..113b76a 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 (@code{,}) e.g.: @code{a:0,v} > @end table > > @subsection Examples > diff --git a/libavformat/tee.c b/libavformat/tee.c > index e3d466a..7d67652 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, , )) < 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 = av_strtok(first_subselect, slave_select_sep, > _subselect)) { > +first_subselect = NULL; I was about to say "LGTM", but I just noticed this: av_strtok(), just like strtok(), is destructive: it replace the delimiters by a NUL character in the original string. If it is called again with the same string, it will only see the first token. Unless I am mistaken, this is what will happen here: if the specifier is "0,1", the stream #0 will be matched on the first round of the loop, but then stream #1 will only see select as "0", no longer "0,1". Fixing it can be done easily enough, though. For example with av_strdup() on the string (but beware of the leaks). I am a bit surprised you did not catch this during testing. Maybe I am missing something. > + > +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, -- Nicolas George signature.asc Description: Digital signature
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
See my interleaved comments below. 2015.10.04. 18:50 keltezéssel, Nicolas George írta: Le decadi 10 vendémiaire, an CCXXIV, Bodecs Bela a écrit : thank you for your feedback, I have altered the patch accordingly. I have enclosed the updated patch file. Please remember not to top-post on these mailing-lists. I am very sorry. I won't do it again. See interleaved comments below. From bcbd5e3e1a850fef1002d3a63c06fc52b2a3d169 Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Thu, 1 Oct 2015 13:00:50 +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" This is rather strange. I wonder how you managed to produce this patch. git add libavformat/tee.c git add doc/muxers.texi git commit -m "select attribute of tee pseudo demuxer may contain multiple stream specifiers" git format-patch -n -o /tmp/ --attach origin diff --git a/doc/muxers.texi b/doc/muxers.texi index d75d7de..113b76a 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 (@code{,}) e.g.: @code{a:0,v} @end table @subsection Examples diff --git a/libavformat/tee.c b/libavformat/tee.c index e3d466a..7d67652 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, , )) < 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 = av_strtok(first_subselect, slave_select_sep, _subselect)) { +first_subselect = NULL; I was about to say "LGTM", but I just noticed this: av_strtok(), just like strtok(), is destructive: it replace the delimiters by a NUL character in the original string. If it is called again with the same string, it will only see the first token. Unless I am mistaken, this is what will happen here: if the specifier is "0,1", the stream #0 will be matched on the first round of the loop, but then stream #1 will only see select as "0", no longer "0,1". Fixing it can be done easily enough, though. For example with av_strdup() on the string (but beware of the leaks). I am a bit surprised you did not catch this during testing. Maybe I am missing something. You would be right unless I used first_subselect = NULL; right after the while statement, so the next round av_strtok will go further, because the first parameter will be null, not the same string and next_subselect will point the next start. Yes it is destructive, but we never use this string (select) again in this function. I swear, I have really tested it, I use it on my own in my production environment. + +ret = avformat_match_stream_specifier(avf, avf->streams[i], subselect); +if (ret < 0) { +av_log(avf, AV_LOG_ERROR, +"Invalid
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
Le tridi 13 vendémiaire, an CCXXIV, Bodecs Bela a écrit : > git format-patch -n -o /tmp/ --attach origin Thanks. Any particular reason to use --attach? It is not a big issue, just a matter of curiosity. > >>@@ -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 = av_strtok(first_subselect, > >>slave_select_sep, _subselect)) { > >>+first_subselect = NULL; > You would be right unless I used > > first_subselect = NULL; > > right after the while statement, so the next round av_strtok will go > further, because the first parameter will be null, not the same string and > next_subselect will point the next start. > Yes it is destructive, but we never use this string (select) again in this > function. I suspect we are talking at cross-purpose here. The "first_subselect = NULL" you are talking about is in the while loop for av_strtok(), it is indeed the normal way of using av_strtok(). But I was talking about the surrounding for loop that goes over all the streams. I left the code quoted above for reference. For i=0, the code is valid, but as soon as i>=1, "first_subselect = select" will use a truncated string > I swear, I have really tested it, I use it on my own in my production > environment. I do not believe that you neglected to test it (nor that you are lying, of course!), I am just really surprised. Just to be sure, I just tested, adding a debug log just after "first_subselect = select", with the following command-line: ./ffmpeg_g -lavfi 'testsrc=r=5;testsrc=r=7;testsrc=r=11' \ -c:v rawvideo -f tee '[f=framecrc:select=0,1]-' I get the following output: select = '0,1' select = '0' Last message repeated 1 times [tee @ 0x36143e0] Input stream #1 is not mapped to any slave. [tee @ 0x36143e0] Input stream #2 is not mapped to any slave. The second "select =" line shows that it is working with a truncated line, and stream #1 should be mapped. Indeed, if I swap the specifiers: "1,0", it maps #0 and #1: #0 is matched first while the string is still intact, #1 is matched by the truncated string. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
2015.10.04. 20:06 keltezéssel, Nicolas George írta: Le tridi 13 vendémiaire, an CCXXIV, Bodecs Bela a écrit : git format-patch -n -o /tmp/ --attach origin Thanks. Any particular reason to use --attach? It is not a big issue, just a matter of curiosity. I thought I should use it this way to be able to send the created patch file later with any mailer. @@ -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 = av_strtok(first_subselect, slave_select_sep, _subselect)) { +first_subselect = NULL; You would be right unless I used first_subselect = NULL; right after the while statement, so the next round av_strtok will go further, because the first parameter will be null, not the same string and next_subselect will point the next start. Yes it is destructive, but we never use this string (select) again in this function. I suspect we are talking at cross-purpose here. The "first_subselect = NULL" you are talking about is in the while loop for av_strtok(), it is indeed the normal way of using av_strtok(). But I was talking about the surrounding for loop that goes over all the streams. I left the code quoted above for reference. For i=0, the code is valid, but as soon as i>=1, "first_subselect = select" will use a truncated string I swear, I have really tested it, I use it on my own in my production environment. I do not believe that you neglected to test it (nor that you are lying, of course!), I am just really surprised. Just to be sure, I just tested, adding a debug log just after "first_subselect = select", with the following command-line: ./ffmpeg_g -lavfi 'testsrc=r=5;testsrc=r=7;testsrc=r=11' \ -c:v rawvideo -f tee '[f=framecrc:select=0,1]-' I get the following output: select = '0,1' select = '0' Last message repeated 1 times [tee @ 0x36143e0] Input stream #1 is not mapped to any slave. [tee @ 0x36143e0] Input stream #2 is not mapped to any slave. The second "select =" line shows that it is working with a truncated line, and stream #1 should be mapped. Indeed, if I swap the specifiers: "1,0", it maps #0 and #1: #0 is matched first while the string is still intact, #1 is matched by the truncated string. Regards, you are right. It is my mistake that I did not test it thoughtfully. It was bad luck why I did not receive error still now. I will correct the patch as soon as possible and send it again. I think I will use the av_strdup() to correct it. (and av_free, of course) thank you, Bela Bodecs ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
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.0 +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, , )) < 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, _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 BodecsDate: 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
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
thank you for your feedback, I have altered the patch accordingly. I have enclosed the updated patch file. bb 2015.10.01. 10:44 keltezéssel, Moritz Barsnick írta: -all the input streams. +all the input streams. You may use multiple stream specifiers +separated by commas (,) eg.: a:0,v eg. -> e.g. (and you have double spaces there, " "). And I prefer "(@code{,})" and "@code{a:0,v}", but perhaps that's a matter of preference, not sure about this yet. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From bcbd5e3e1a850fef1002d3a63c06fc52b2a3d169 Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Thu, 1 Oct 2015 13:00:50 +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..113b76a 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 (@code{,}) e.g.: @code{a:0,v} @end table @subsection Examples diff --git a/libavformat/tee.c b/libavformat/tee.c index e3d466a..7d67652 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, , )) < 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 = av_strtok(first_subselect, slave_select_sep, _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
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
> -all the input streams. > +all the input streams. You may use multiple stream specifiers > +separated by commas (,) eg.: a:0,v eg. -> e.g. (and you have double spaces there, " "). And I prefer "(@code{,})" and "@code{a:0,v}", but perhaps that's a matter of preference, not sure about this yet. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
Sorry I have enclosed an earlier patch file in my previous email. This is the good one. bb 2015.10.01. 10:22 keltezéssel, Bodecs Bela írta: 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.0 +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, , )) < 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, _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 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From 6eb4856f0058838a53170f763f395692088ea121 Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Thu, 1 Oct 2015 10:31:17 +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;
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
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.0 +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, , )) < 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, > _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, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
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 From 45330b5bdf77f0b424d2631bddfc61bfdcc5901d Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: 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, , )) < 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, _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
[FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
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.0 +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, , )) < 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, _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; } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel