[FFmpeg-devel] [RFC] lavf/tee per-output stream selection
Stefano Sabatini
stefasab at gmail.com
Thu Aug 8 12:36:38 CEST 2013
On date Sunday 2013-08-04 12:07:14 +0200, Nicolas George encoded:
> Le sextidi 16 thermidor, an CCXXI, Stefano Sabatini a écrit :
> > >From 7b08890d825abc7df66bd49e8cbb1f4ae5c888b1 Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefasab at gmail.com>
> > Date: Sat, 3 Aug 2013 11:23:59 +0200
> > Subject: [PATCH] lavf/tee: add special select option
> >
> > TODO: bump micro
> > ---
> > doc/muxers.texi | 5 +++++
> > libavformat/tee.c | 48 ++++++++++++++++++++++++++++++++++++++++--------
> > 2 files changed, 45 insertions(+), 8 deletions(-)
> >
> > diff --git a/doc/muxers.texi b/doc/muxers.texi
> > index 7c5a1c8..37a1734 100644
> > --- a/doc/muxers.texi
> > +++ b/doc/muxers.texi
> > @@ -844,6 +844,11 @@ The BNF description of the bitstream filters specification is given by:
> > @var{BSF} ::= @var{BSF_NAME}[+ at var{STREAM_SPECIFIER}]
> > @var{BSFS} ::= @var{BSF}[, at var{BSFS}]
> > @end example
> > +
> > + at 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.
>
> Examples may be welcome. Is it possible to have several stream specifiers,
> i.e. map "video + English audio + French audio" to "video + English audio"
> and "video + French audio"?
Not at the moment, see my other reply.
>
> > @end table
> >
> > Example: encode something and both archive it in a WebM file and stream it
> > diff --git a/libavformat/tee.c b/libavformat/tee.c
> > index 90947c7..4604ab4 100644
> > --- a/libavformat/tee.c
> > +++ b/libavformat/tee.c
> > @@ -30,6 +30,7 @@
> > typedef struct {
> > AVFormatContext *fmt_ctx;
> > AVBitStreamFilterContext **bsf_ctxs; ///< bitstream filters per stream
>
> > + int *stream_map; ///< map between input and output streams, disabled streams are set to -1
>
> Nit: please try to keep lines below 80 chars.
>
> Also, the comment is unclear about the direction of the map, it could be
> either:
>
> stream_num_in_slave = stream_map[stream_num_in_global]
> stream_num_in_global = stream_map[stream_num_in_slave]
Changed.
>
> > } TeeSlave;
> >
> > typedef struct TeeContext {
> > @@ -179,9 +180,10 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
> > AVDictionary *options = NULL;
> > AVDictionaryEntry *entry;
> > char *filename;
> > - char *format = NULL, *bsfs = NULL;
> > + char *format = NULL, *bsfs = NULL, *select = NULL;
> > AVFormatContext *avf2 = NULL;
> > AVStream *st, *st2;
> > + int stream_count;
> >
> > if ((ret = parse_slave_options(avf, slave, &options, &filename)) < 0)
> > return ret;
> > @@ -195,14 +197,42 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
> > entry->value = NULL; /* prevent it from being freed */
> > av_dict_set(&options, "bsfs", NULL, 0);
> > }
> > + if ((entry = av_dict_get(options, "select", NULL, 0))) {
> > + select = entry->value;
> > + entry->value = NULL; /* prevent it from being freed */
> > + av_dict_set(&options, "select", NULL, 0);
> > + }
>
> This hunk really needs factoring.
Done through a macro.
>
> >
> > ret = avformat_alloc_output_context2(&avf2, NULL, format, filename);
> > if (ret < 0)
> > goto fail;
> > av_free(format);
> >
> > + tee_slave->stream_map = av_calloc(avf->nb_streams, sizeof(int));
>
> sizeof(*tee_slave->stream_map)
>
> > + if (!tee_slave->stream_map) {
> > + ret = AVERROR(ENOMEM);
> > + goto fail;
> > + }
> > +
> > + stream_count = 0;
> > for (i = 0; i < avf->nb_streams; i++) {
> > st = avf->streams[i];
>
> > + if (select && select[0]) {
>
> Why select[0]?
Changed.
[...]
Patches updated. They depend on the per-stream bitstream filtering patch.
--
FFmpeg = Friendly and Faithless Mystic Proud Elitarian Game
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavf-tee-add-special-select-option.patch
Type: text/x-diff
Size: 5348 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130808/572c2d7e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-doc-muxers-add-elaborated-example-for-the-tee-muxer.patch
Type: text/x-diff
Size: 1406 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130808/572c2d7e/attachment-0001.bin>
More information about the ffmpeg-devel
mailing list