File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -640,11 +640,12 @@ void VideoEncoder::initializeEncoder(
640
640
// For codecs that don't support CRF (mpeg4, flv1),
641
641
// use quality-based encoding via global_quality + qscale flag
642
642
avCodecContext_->flags |= AV_CODEC_FLAG_QSCALE;
643
- // While qscale is similar to crf, it is likely not interchangeable.
644
- // Reuse of crf below is only intended to work in VideoEncoder tests where
645
- // crf = 0
646
- avCodecContext_->global_quality =
647
- FF_QP2LAMBDA * videoStreamOptions.crf .value ();
643
+ // Reuse of crf below is only intended to work in tests where crf = 0
644
+ // Use qmin as lower bound for best possible quality
645
+ int qp = videoStreamOptions.crf .value () <= avCodecContext_->qmin
646
+ ? avCodecContext_->qmin
647
+ : videoStreamOptions.crf .value ();
648
+ avCodecContext_->global_quality = FF_QP2LAMBDA * qp;
648
649
}
649
650
int status = avcodec_open2 (avCodecContext_.get (), avCodec, &options);
650
651
av_dict_free (&options);
You can’t perform that action at this time.
0 commit comments