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

Nicolas George george at nsup.org
Wed Sep 30 15:53:43 CEST 2015


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,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150930/939771d8/attachment.sig>


More information about the ffmpeg-devel mailing list