diff mbox series

[FFmpeg-devel] Fix wrong time_base bug

Message ID 20210312174709.406672-1-donoughliu@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel] Fix wrong time_base bug | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Donough Liu March 12, 2021, 5:47 p.m. UTC
Set time_base to inv of frame rate is only valid when input video have fixed frame rate.

Signed-off-by: Donough Liu <donoughliu@gmail.com>
---
 doc/examples/transcoding.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anton Khirnov March 14, 2021, 11:14 a.m. UTC | #1
Quoting Donough Liu (2021-03-12 18:47:09)
> Set time_base to inv of frame rate is only valid when input video have fixed frame rate.
> 
> Signed-off-by: Donough Liu <donoughliu@gmail.com>
> ---
>  doc/examples/transcoding.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
> index 5aff08c135..d6fed63421 100644
> --- a/doc/examples/transcoding.c
> +++ b/doc/examples/transcoding.c
> @@ -170,7 +170,7 @@ static int open_output_file(const char *filename)
>                  else
>                      enc_ctx->pix_fmt = dec_ctx->pix_fmt;
>                  /* video time_base can be set to whatever is handy and supported by encoder */
> -                enc_ctx->time_base = av_inv_q(dec_ctx->framerate);
> +                enc_ctx->time_base = dec_ctx->time_base;

This is wrong, the use of time_base for decoding is deprecated.
Donough Liu March 14, 2021, 1:10 p.m. UTC | #2
But using framerate to calculate time_base is also an error, you can try
transcoding this video:
https://drive.google.com/file/d/1bOV90UP61GbSAyzgsfzBZAOU_9feLPpm/view?usp=sharing

On Sun, Mar 14, 2021 at 7:14 PM Anton Khirnov <anton@khirnov.net> wrote:

> Quoting Donough Liu (2021-03-12 18:47:09)
> > Set time_base to inv of frame rate is only valid when input video have
> fixed frame rate.
> >
> > Signed-off-by: Donough Liu <donoughliu@gmail.com>
> > ---
> >  doc/examples/transcoding.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
> > index 5aff08c135..d6fed63421 100644
> > --- a/doc/examples/transcoding.c
> > +++ b/doc/examples/transcoding.c
> > @@ -170,7 +170,7 @@ static int open_output_file(const char *filename)
> >                  else
> >                      enc_ctx->pix_fmt = dec_ctx->pix_fmt;
> >                  /* video time_base can be set to whatever is handy and
> supported by encoder */
> > -                enc_ctx->time_base = av_inv_q(dec_ctx->framerate);
> > +                enc_ctx->time_base = dec_ctx->time_base;
>
> This is wrong, the use of time_base for decoding is deprecated.
>
> --
> Anton Khirnov
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index 5aff08c135..d6fed63421 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -170,7 +170,7 @@  static int open_output_file(const char *filename)
                 else
                     enc_ctx->pix_fmt = dec_ctx->pix_fmt;
                 /* video time_base can be set to whatever is handy and supported by encoder */
-                enc_ctx->time_base = av_inv_q(dec_ctx->framerate);
+                enc_ctx->time_base = dec_ctx->time_base;
             } else {
                 enc_ctx->sample_rate = dec_ctx->sample_rate;
                 enc_ctx->channel_layout = dec_ctx->channel_layout;