[FFmpeg-devel] [PATCH] avcodec/setts_bsf: allow to use input stream timebase too

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Aug 22 15:47:54 EEST 2021


Paul B Mahol:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  doc/bitstream_filters.texi | 5 ++++-
>  libavcodec/setts_bsf.c     | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index 1900eb4352..b5a0be8ca2 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -777,8 +777,11 @@ The previous output DTS.
>  @item PREV_OUTPTS
>  The previous output PTS.
>  
> + at item ITB
> +The input timebase of stream packet belongs.
> +
>  @item TB
> -The timebase of stream packet belongs.
> +The output timebase of stream packet belongs.
>  
>  @item SR
>  The sample rate of stream packet belongs.
> diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
> index d604f91f71..965c999500 100644
> --- a/libavcodec/setts_bsf.c
> +++ b/libavcodec/setts_bsf.c
> @@ -41,7 +41,8 @@ static const char *const var_names[] = {
>      "DTS",         ///< original DTS in the file of the frame
>      "STARTPTS",    ///< PTS at start of movie
>      "STARTDTS",    ///< DTS at start of movie
> -    "TB",          ///< timebase of the stream
> +    "ITB",         ///< input timebase of the stream
> +    "TB",          ///< output timebase of the stream
>      "SR",          ///< sample rate of the stream
>      "NOPTS",       ///< The AV_NOPTS_VALUE constant
>      NULL
> @@ -59,6 +60,7 @@ enum var_name {
>      VAR_DTS,
>      VAR_STARTPTS,
>      VAR_STARTDTS,
> +    VAR_ITB,
>      VAR_TB,
>      VAR_SR,
>      VAR_NOPTS,
> @@ -154,6 +156,7 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
>      s->var_values[VAR_PREV_OUTDTS] = s->prev_outdts;
>      s->var_values[VAR_STARTPTS]    = s->start_pts;
>      s->var_values[VAR_STARTDTS]    = s->start_dts;
> +    s->var_values[VAR_ITB]         = ctx->time_base_in.den  ? av_q2d(ctx->time_base_in)  : 0;
>      s->var_values[VAR_TB]          = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0;
>      s->var_values[VAR_SR]          = ctx->par_in->sample_rate;
>  
> 
This is of no use: It is the user which sets the input timebase and it
is the bsf which (in its init function) chooses the output timebase (the
generic bsf code sets it equal to the input timebase and most (all?)
filters don't change it). This filter does not change it, so input and
output timebases are always equal.

The bug in #9382 is really in ffmpeg.c, it can't be fixed in this bsf at
all as it lacks the information about the muxing timebase.

- Andreas


More information about the ffmpeg-devel mailing list