[FFmpeg-user] A53 Captions Garbled If Frame Duplication Occurs
Shane Warren
shanew at innovsys.com
Sat May 4 00:47:47 EEST 2024
I ingest some multicast video that has a53 captions embedded in h264 video, the video claims to have a framerate of 29.97 but it must not quite be that because ffmpeg duplicates frames when transcoding this stream. The output stream has a53 captions, but they appear to be somewhat garbled, like some letters are duplicated, sometimes.
I decided to git bisect since I knew this worked in a much older ffmpeg binary I had. I finally found the commit that broke this:
a11ab647304307d0340fd052e04cf638b6bef309 : fftools/ffmpeg: share the code encoding a single frame between video and audio
Call do_video_stats() for every video packet produced by the encoder,
rather than for every frame sent to the encoder.
------------------------------------------------------------------------
The key part that was missed in this commit was calling this directly after avcodec_send_frame:
// Make sure Closed Captions will not be duplicated
av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
I fixed this in that commit, and captions worked again. I tried to fix it the same way in a the current ffmpeg source by changing:
ffmpeg_enc.c encode_frame:
ret = avcodec_send_frame(enc, frame);
if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
av_log(ost, AV_LOG_ERROR, "Error submitting %s frame to the encoder\n",
type_desc);
return ret;
}
+if (frame != NULL)
+{
+ av_frame_remove_side_data(frame, AV_FRAME_DATA_A53_CC);
+}
But that didn't fix the problem, I suspect this is needed when a frame is duplicated, but I can't figure out the place to put that.
Anyone have any ideas what I need to change to get captions working in the current ffmpeg source?
More information about the ffmpeg-user
mailing list