@@ -2218,6 +2218,11 @@ static int open_output_file(OptionsContext *o, const char *filename)
double score;
ist = input_streams[i];
+ if (ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+ ist->user_set_discard == AVDISCARD_ALL ||
+ (qcr == MKTAG('A', 'P', 'I', 'C') && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)))
+ continue;
+
/* base score is just the area in pixels */
score = (double)ist->st->codecpar->width * ist->st->codecpar->height;
/* add a fractional part favoring higher bitrate among same-area streams */
@@ -2230,14 +2235,10 @@ static int open_output_file(OptionsContext *o, const char *filename)
if (ist->st->disposition & AV_DISPOSITION_DEFAULT)
score = DBL_MAX;
- if (ist->user_set_discard == AVDISCARD_ALL)
- continue;
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
score = 1;
- if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
- score > best_score) {
- if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
- continue;
+
+ if (score > best_score) {
best_score = score;
idx = i;
}