diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-07-07 11:31:53 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-07-15 11:02:11 +0200 |
commit | dff3a283cd8c71802d43fbbbfcf57fb479784a24 (patch) | |
tree | 5ad71cc5725849df33d2c4b15b42846e9889585f /fftools/ffmpeg_enc.c | |
parent | 4d06742b93394b6265fb32640ee7bb36f4fe1a06 (diff) | |
download | ffmpeg-dff3a283cd8c71802d43fbbbfcf57fb479784a24.tar.gz |
fftools/ffmpeg: rework -enc_time_base handling
Read the timebase from FrameData rather than the input stream. This
should fix #10393 and generally be more reliable.
Replace the use of '-1' to indicate demuxing timebase with the string
'demux'. Also allow to request filter timebase with
'-enc_time_base filter'.
Diffstat (limited to 'fftools/ffmpeg_enc.c')
-rw-r--r-- | fftools/ffmpeg_enc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 0e2285c5a2..1489b2f179 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -264,8 +264,20 @@ int enc_open(OutputStream *ost, AVFrame *frame) fr.num, fr.den, 65535); } - enc_ctx->time_base = ost->enc_timebase.num > 0 ? ost->enc_timebase : - av_inv_q(fr); + if (ost->enc_timebase.num == ENC_TIME_BASE_DEMUX) { + if (fd->dec.tb.num <= 0 || fd->dec.tb.den <= 0) { + av_log(ost, AV_LOG_ERROR, + "Demuxing timebase not available - cannot use it for encoding\n"); + return AVERROR(EINVAL); + } + + enc_ctx->time_base = fd->dec.tb; + } else if (ost->enc_timebase.num == ENC_TIME_BASE_FILTER) { + enc_ctx->time_base = frame->time_base; + } else { + enc_ctx->time_base = ost->enc_timebase.num > 0 ? ost->enc_timebase : + av_inv_q(fr); + } if (!(enc_ctx->time_base.num && enc_ctx->time_base.den)) enc_ctx->time_base = frame->time_base; |