Skip to content

Commit

Permalink
ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid
Browse files Browse the repository at this point in the history
This ensures old commandlines using -hwaccel cuvid don't break due to
the recent removal of the the cuvid-specific hwaccel bringup.
  • Loading branch information
BtbN committed Mar 7, 2020
1 parent cfd9a65 commit cb3c77c
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions fftools/ffmpeg_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);

MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
hwaccel_output_format, ic, st);

if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
av_log(NULL, AV_LOG_WARNING,
"WARNING: defaulting hwaccel_output_format to cuda for compatibility "
"with old commandlines. This behaviour is DEPRECATED and will be removed "
"in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
ist->hwaccel_output_format = AV_PIX_FMT_CUDA;
} else if (hwaccel_output_format) {
ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
"format: %s", hwaccel_output_format);
}
} else {
ist->hwaccel_output_format = AV_PIX_FMT_NONE;
}

if (hwaccel) {
// The NVDEC hwaccels use a CUDA device, so remap the name here.
if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
Expand Down Expand Up @@ -868,18 +887,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
exit_program(1);
}

MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
hwaccel_output_format, ic, st);
if (hwaccel_output_format) {
ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
"format: %s", hwaccel_output_format);
}
} else {
ist->hwaccel_output_format = AV_PIX_FMT_NONE;
}

ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;

break;
Expand Down

0 comments on commit cb3c77c

Please sign in to comment.