Check if the codec supports CRF when setting q values

This commit is contained in:
eisneinechse
2019-03-10 13:09:47 -07:00
parent b5ebc996ee
commit a170d7db38

View File

@@ -1140,13 +1140,28 @@ AVStream* FFmpegWriter::add_video_stream()
// Defaults are used because mpeg2 otherwise had problems
}
else {
if (info.video_bit_rate < 40) {
c->qmin = 0;
c->qmax = 63;
}
else {
c->qmin = info.video_bit_rate - 5;
c->qmax = 63;
// Check if codec supports crf
switch (c->codec_id) {
#if (LIBAVCODEC_VERSION_MAJOR >= 58)
case AV_CODEC_ID_AV1 :
#endif
case AV_CODEC_ID_VP8 :
case AV_CODEC_ID_VP9 :
case AV_CODEC_ID_H264 :
case AV_CODEC_ID_H265 :
if (info.video_bit_rate < 40) {
c->qmin = 0;
c->qmax = 63;
}
else {
c->qmin = info.video_bit_rate - 5;
c->qmax = 63;
}
break;
default:
// Here should be the setting for codecs that don't support crf
// For now defaults are used
break;
}
}