Make mime-type award a bonus probe score

This changes the default behaviour of ffmpeg where content-type headers
on an input gives an absolut probe score (of 75) to instead give a bonus
score (of 30). This gives the probe a better chance to arrive at the
correct format by (hopefully) giving a large enough bonus to push edge
cases in the right direction (MPEG-PS vs MP3, I am looking at you) while
also not adversly punishing clearer cases (raw ADTS marked as
"audio/mpeg" for example).

This patch was regression tested against 20 million recent podcast
submissions (after content-type propagation was added to
original-storage), and 50k Juno vodcasts submissions (dito). No adverse
effects observed (but the bonus may still need tweaking if other edge
cases are detected in production).
This commit is contained in:
Peter Zebühr 2023-11-21 14:16:49 +01:00 committed by Tomas Härdin
parent 5a526fdad0
commit e24920375c
3 changed files with 6 additions and 6 deletions

View file

@ -212,10 +212,10 @@ const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
score = AVPROBE_SCORE_EXTENSION;
}
if (av_match_name(lpd.mime_type, fmt1->mime_type)) {
if (AVPROBE_SCORE_MIME > score) {
av_log(NULL, AV_LOG_DEBUG, "Probing %s score:%d increased to %d due to MIME type\n", fmt1->name, score, AVPROBE_SCORE_MIME);
score = AVPROBE_SCORE_MIME;
}
int old_score = score;
score += AVPROBE_SCORE_MIME_BONUS;
if (score > AVPROBE_SCORE_MAX) score = AVPROBE_SCORE_MAX;
av_log(NULL, AV_LOG_DEBUG, "Probing %s score:%d increased to %d due to MIME type\n", fmt1->name, old_score, score);
}
if (score > score_max) {
score_max = score;