mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
cmdutils: add support for programs in check_stream_specifier()
Remove now redundant (and broken/undocumented) opt_programid.
This commit is contained in:
parent
05bffc12c4
commit
2c474ddbc5
44
avconv.c
44
avconv.c
@ -140,7 +140,6 @@ static int copy_tb;
|
|||||||
static int opt_shortest = 0;
|
static int opt_shortest = 0;
|
||||||
static char *vstats_filename;
|
static char *vstats_filename;
|
||||||
static FILE *vstats_file;
|
static FILE *vstats_file;
|
||||||
static int opt_programid = 0;
|
|
||||||
static int copy_initial_nonkeyframes = 0;
|
static int copy_initial_nonkeyframes = 0;
|
||||||
|
|
||||||
static int audio_volume = 256;
|
static int audio_volume = 256;
|
||||||
@ -1892,7 +1891,7 @@ static int transcode_init(OutputFile *output_files,
|
|||||||
InputFile *input_files,
|
InputFile *input_files,
|
||||||
int nb_input_files)
|
int nb_input_files)
|
||||||
{
|
{
|
||||||
int ret = 0, i, j;
|
int ret = 0, i, j, k;
|
||||||
AVFormatContext *os;
|
AVFormatContext *os;
|
||||||
AVCodecContext *codec, *icodec;
|
AVCodecContext *codec, *icodec;
|
||||||
OutputStream *ost;
|
OutputStream *ost;
|
||||||
@ -2190,6 +2189,22 @@ static int transcode_init(OutputFile *output_files,
|
|||||||
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0)
|
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0)
|
||||||
goto dump_format;
|
goto dump_format;
|
||||||
|
|
||||||
|
/* discard unused programs */
|
||||||
|
for (i = 0; i < nb_input_files; i++) {
|
||||||
|
InputFile *ifile = &input_files[i];
|
||||||
|
for (j = 0; j < ifile->ctx->nb_programs; j++) {
|
||||||
|
AVProgram *p = ifile->ctx->programs[j];
|
||||||
|
int discard = AVDISCARD_ALL;
|
||||||
|
|
||||||
|
for (k = 0; k < p->nb_stream_indexes; k++)
|
||||||
|
if (!input_streams[ifile->ist_index + p->stream_index[k]].discard) {
|
||||||
|
discard = AVDISCARD_DEFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p->discard = discard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* open files and write file headers */
|
/* open files and write file headers */
|
||||||
for (i = 0; i < nb_output_files; i++) {
|
for (i = 0; i < nb_output_files; i++) {
|
||||||
os = output_files[i].ctx;
|
os = output_files[i].ctx;
|
||||||
@ -2904,30 +2919,6 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena
|
|||||||
}
|
}
|
||||||
assert_avoptions(format_opts);
|
assert_avoptions(format_opts);
|
||||||
|
|
||||||
if(opt_programid) {
|
|
||||||
int i, j;
|
|
||||||
int found=0;
|
|
||||||
for(i=0; i<ic->nb_streams; i++){
|
|
||||||
ic->streams[i]->discard= AVDISCARD_ALL;
|
|
||||||
}
|
|
||||||
for(i=0; i<ic->nb_programs; i++){
|
|
||||||
AVProgram *p= ic->programs[i];
|
|
||||||
if(p->id != opt_programid){
|
|
||||||
p->discard = AVDISCARD_ALL;
|
|
||||||
}else{
|
|
||||||
found=1;
|
|
||||||
for(j=0; j<p->nb_stream_indexes; j++){
|
|
||||||
ic->streams[p->stream_index[j]]->discard= AVDISCARD_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found){
|
|
||||||
fprintf(stderr, "Specified program id not found\n");
|
|
||||||
exit_program(1);
|
|
||||||
}
|
|
||||||
opt_programid=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* apply forced codec ids */
|
/* apply forced codec ids */
|
||||||
for (i = 0; i < ic->nb_streams; i++)
|
for (i = 0; i < ic->nb_streams; i++)
|
||||||
choose_codec(o, ic, ic->streams[i], ic->streams[i]->codec->codec_type);
|
choose_codec(o, ic, ic->streams[i], ic->streams[i]->codec->codec_type);
|
||||||
@ -4018,7 +4009,6 @@ static const OptionDef options[] = {
|
|||||||
{ "copytb", OPT_BOOL | OPT_EXPERT, {(void*)©_tb}, "copy input stream time base when stream copying" },
|
{ "copytb", OPT_BOOL | OPT_EXPERT, {(void*)©_tb}, "copy input stream time base when stream copying" },
|
||||||
{ "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
|
{ "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
|
||||||
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
|
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
|
||||||
{ "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
|
|
||||||
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
|
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
|
||||||
{ "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" },
|
{ "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" },
|
||||||
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" },
|
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" },
|
||||||
|
20
cmdutils.c
20
cmdutils.c
@ -841,6 +841,26 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (*spec == 'p' && *(spec + 1) == ':') {
|
||||||
|
int prog_id, i, j;
|
||||||
|
char *endptr;
|
||||||
|
spec += 2;
|
||||||
|
prog_id = strtol(spec, &endptr, 0);
|
||||||
|
for (i = 0; i < s->nb_programs; i++) {
|
||||||
|
if (s->programs[i]->id != prog_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (*endptr++ == ':') {
|
||||||
|
int stream_idx = strtol(endptr, NULL, 0);
|
||||||
|
return (stream_idx >= 0 && stream_idx < s->programs[i]->nb_stream_indexes &&
|
||||||
|
st->index == s->programs[i]->stream_index[stream_idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
|
||||||
|
if (st->index == s->programs[i]->stream_index[j])
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
} else if (!*spec) /* empty specifier, matches everything */
|
} else if (!*spec) /* empty specifier, matches everything */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user