[FFmpeg-devel] [PATCH] fftools/ffmpeg_enc: Prevent duplicate A53 Closed Captions at frame rate up-conversion

Anton Khirnov anton at khirnov.net
Sun Jun 11 06:55:56 EEST 2023


Quoting Devin Heitmueller (2023-06-09 17:13:17)
> Hi Artem,
> 
> On Fri, Jun 9, 2023 at 9:19 AM Artem Smorodin
> <artem.smorodin at telestream.net> wrote:
> >
> > When up-converting frame rate, ffmpeg duplicates frames including side data. This causes duplicated characters in the output. This patch removes A53 side data from duplicated frames.
> >
> > Signed-off-by: Artem Smorodin <artem.smorodin at telestream.net>
> > ---
> >  fftools/ffmpeg_enc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
> > index 2bf4782a9f..93d18034ca 100644
> > --- a/fftools/ffmpeg_enc.c
> > +++ b/fftools/ffmpeg_enc.c
> > @@ -1104,6 +1104,9 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
> >          else if (ret < 0)
> >              exit_program(1);
> >
> > +        //Prevent duplicate Closed Captions at frame rate up-conversion
> > +        av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
> > +
> >          e->next_pts++;
> >          e->vsync_frame_number++;
> >      }
> > --
> > 2.25.1
> >
> > Disclaimer
> 
> Unfortunately, the patch needed is more complicated than what you're
> proposed.  You can't simply drop the caption from the duplicated
> frame, but rather the CC data needs to be rewritten in existing frames
> with the appropriate cc_count and distribution of 608 pairs.
> 
> I've reworked the logic to behave correctly if you use the "fps" video
> filter, but had forgotten that using "-r" doesn't use that filter.
> 
> Anton, is there any good reason we couldn't rework the "-r" command
> line argument to invoke the fps filter (like we do with scaling)
> rather than re-implementing the same functionality inside of the
> ffmpeg program itself?  It always seemed strange to me that it didn't
> work that way from the beginning...

I don't think there's a fundamental reason -r handling could not be
moved to lavfi, but it's a nontrivial task. E.g. the dup/drop counts are
integrated with the CLI and would have to be exported from lavfi somehow
if you wanted to keep that functionality.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list