[FFmpeg-devel] [PATCH] options to set stream id (custom TS pid)

Baptiste Coudurier baptiste.coudurier
Sun Jun 6 22:48:51 CEST 2010


On 6/5/10 10:30 AM, Mike Scheutzow wrote:
> Here are updated patches incorporating Baptiste's comments.
>
> Baptiste Coudurier wrote:
>> The < 16 check is useless.
> Fixed. I also added a check for id values > 0x1FFF.
>> Well, I'm not sure what we want to do
>>
>> avformat.h:
>> * @param id file-format-dependent stream ID
>>
>> I don't know why we want to set it to stream index here.
>> IMHO I would set it to 0 assuming it has no side effect.
>> I quickly check before the last patch and I didn't see st->id usage,
>> but I could have missed it.
>> No strong feeling, initing streamid_map just for this seems a waste.
> Patch modified so that an unspecified stream id is now set to 0 in the
> AVStream struct. The streamid_map[] init operation is removed from
> main(), but a simplified form is still present in the output_file handler.
>> ffmpeg -i in.ts -vcodec copy -streamid 0:33 -streamid 1:36 -acodec mp2
>> out1.ts -vcodec copy -acodec ac3 out2.ts
>>
>> Would also set out2 stream ids, it might not be wanted, not sure,
> Your assumption about a second output file is not correct. I think the
> most intuitive behavior is that the scope of a -streamid value ends at
> the output file name. There is code in my original patch to reset the
> streamid_map[] array to default values in the output_file handler. I
> tested this behavior, and it worked as desired.
>
>
> ffmpeg_set_streamid_v2.patch
>
> [...]
 >
> @@ -3750,6 +3774,8 @@
>       oc->flags |= AVFMT_FLAG_NONBLOCK;
>
>       set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM);
> +
> +    memset( streamid_map, 0, sizeof(streamid_map) );
>   }

Parantheses placement.

 > [...]
 >
> @@ -420,6 +425,26 @@
>           st->priv_data = ts_st;
>           ts_st->service = service;
>           ts_st->pid = DEFAULT_START_PID + i;
> +        /* maintain compatibility for apps that set st->id to AVStream index */
> +        if (st->id>= 16) {

This is not the reason, pid < 16 are reserved.

Except these I'm ok with with the patch.

[...]

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list