[FFmpeg-devel] [PATCH]select attribute of tee pseudo demuxer may contain multiple stream specifiers
Nicolas George
george at nsup.org
Sun Oct 4 20:06:28 CEST 2015
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, &next_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
-------------- 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/20151004/fbf2e60e/attachment.sig>
More information about the ffmpeg-devel
mailing list