Revision 006e8108

View differences:

doc/ffmpeg-doc.texi
638 638
Set the maximum demux-decode delay.
639 639
@item -muxpreload @var{seconds}
640 640
Set the initial demux-decode delay.
641
@item -streamid @var{output-stream-index}:@var{new-value}
642
Assign a new value to a stream's stream-id field in the next output file.
643
All stream-id fields are reset to default for each output file.
644

  
645
For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
646
an output mpegts file:
647
@example
648
ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
649
@end example
641 650
@end table
642 651

  
643 652
@section Preset files
ffmpeg.c
121 121
static AVMetaDataMap meta_data_maps[MAX_FILES];
122 122
static int nb_meta_data_maps;
123 123

  
124
/* indexed by output file stream index */
125
static int streamid_map[MAX_STREAMS];
126

  
124 127
static int frame_width  = 0;
125 128
static int frame_height = 0;
126 129
static float frame_aspect_ratio = 0;
......
3348 3351
    AVCodecContext *video_enc;
3349 3352
    enum CodecID codec_id;
3350 3353

  
3351
    st = av_new_stream(oc, oc->nb_streams);
3354
    st = av_new_stream(oc, streamid_map[oc->nb_streams]);
3352 3355
    if (!st) {
3353 3356
        fprintf(stderr, "Could not alloc stream\n");
3354 3357
        av_exit(1);
......
3486 3489
    AVCodecContext *audio_enc;
3487 3490
    enum CodecID codec_id;
3488 3491

  
3489
    st = av_new_stream(oc, oc->nb_streams);
3492
    st = av_new_stream(oc, streamid_map[oc->nb_streams]);
3490 3493
    if (!st) {
3491 3494
        fprintf(stderr, "Could not alloc stream\n");
3492 3495
        av_exit(1);
......
3559 3562
    AVStream *st;
3560 3563
    AVCodecContext *subtitle_enc;
3561 3564

  
3562
    st = av_new_stream(oc, oc->nb_streams);
3565
    st = av_new_stream(oc, streamid_map[oc->nb_streams]);
3563 3566
    if (!st) {
3564 3567
        fprintf(stderr, "Could not alloc stream\n");
3565 3568
        av_exit(1);
......
3628 3631
    new_subtitle_stream(oc);
3629 3632
}
3630 3633

  
3634
/* arg format is "output-stream-index:streamid-value". */
3635
static void opt_streamid(const char *opt, const char *arg)
3636
{
3637
    int idx;
3638
    char *p;
3639
    char idx_str[16];
3640

  
3641
    strncpy(idx_str, arg, sizeof(idx_str));
3642
    idx_str[sizeof(idx_str)-1] = '\0';
3643
    p = strchr(idx_str, ':');
3644
    if (!p) {
3645
        fprintf(stderr,
3646
                "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
3647
                arg, opt);
3648
        av_exit(1);
3649
    }
3650
    *p++ = '\0';
3651
    idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3652
    streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
3653
}
3654

  
3631 3655
static void opt_output_file(const char *filename)
3632 3656
{
3633 3657
    AVFormatContext *oc;
......
3775 3799
    oc->flags |= AVFMT_FLAG_NONBLOCK;
3776 3800

  
3777 3801
    set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM);
3802

  
3803
    memset(streamid_map, 0, sizeof(streamid_map));
3778 3804
}
3779 3805

  
3780 3806
/* same option as mencoder */
......
4233 4259
    { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" },
4234 4260
    { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
4235 4261
    { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "force the selected framerate, disable the best supported framerate selection" },
4262
    { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
4236 4263

  
4237 4264
    /* audio options */
4238 4265
    { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },

Also available in: Unified diff