mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-11 17:55:21 +00:00
lavc: make avcodec_open2() fail when the timebase is not set for encoding
Many encoders use it. There is also a divide by the timebase lower in this function, which would crash when it is not set.
This commit is contained in:
parent
11de006bab
commit
e62ff72fc1
@ -994,6 +994,13 @@ FF_DISABLE_DEPRECATION_WARNINGS
|
|||||||
}
|
}
|
||||||
FF_ENABLE_DEPRECATION_WARNINGS
|
FF_ENABLE_DEPRECATION_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n");
|
||||||
|
ret = AVERROR(EINVAL);
|
||||||
|
goto free_and_end;
|
||||||
|
}
|
||||||
|
|
||||||
if (avctx->codec->sample_fmts) {
|
if (avctx->codec->sample_fmts) {
|
||||||
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
|
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
|
||||||
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
|
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
|
||||||
|
Loading…
Reference in New Issue
Block a user