Fix: Video CRF being reset when switching to AV1 codec #129050

Merged
Aras Pranckevicius merged 1 commits from aras_p/blender:ffmpeg_crf_codecs_check into main 2024-10-16 05:49:29 +02:00
3 changed files with 9 additions and 10 deletions

View File

@ -67,6 +67,7 @@ void BKE_ffmpeg_filepath_get(char filepath[/*FILE_MAX*/ 1024],
void BKE_ffmpeg_preset_set(RenderData *rd, int preset);
void BKE_ffmpeg_image_type_verify(RenderData *rd, const ImageFormatData *imf);
bool BKE_ffmpeg_alpha_channel_is_supported(const RenderData *rd);
bool BKE_ffmpeg_codec_supports_crf(int av_codec_id);
void *BKE_ffmpeg_context_create();
void BKE_ffmpeg_context_free(void *context_v);

View File

@ -1968,6 +1968,11 @@ bool BKE_ffmpeg_alpha_channel_is_supported(const RenderData *rd)
AV_CODEC_ID_HUFFYUV);
}
bool BKE_ffmpeg_codec_supports_crf(int av_codec_id)
{
return ELEM(av_codec_id, AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP9, AV_CODEC_ID_AV1);
}
void *BKE_ffmpeg_context_create()
{
/* New FFMPEG data struct. */

View File

@ -2953,16 +2953,9 @@ static std::optional<std::string> rna_FFmpegSettings_path(const PointerRNA * /*p
static void rna_FFmpegSettings_codec_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
{
FFMpegCodecData *codec_data = (FFMpegCodecData *)ptr->data;
if (!ELEM(codec_data->codec,
AV_CODEC_ID_H264,
AV_CODEC_ID_MPEG4,
AV_CODEC_ID_VP9,
AV_CODEC_ID_DNXHD))
{
/* Constant Rate Factor (CRF) setting is only available for H264,
* MPEG4 and WEBM/VP9 codecs. So changing encoder quality mode to
* CBR as CRF is not supported.
*/
if (!BKE_ffmpeg_codec_supports_crf(codec_data->codec)) {
/* Constant Rate Factor (CRF) setting is only available for some codecs. Change encoder quality
* mode to CBR for others. */
codec_data->constant_rate_factor = FFM_CRF_NONE;
}
}