Preserve CEA-708 Captions When Transcoding with FFmpeg

When transcoding video files using FFmpeg, preserving CEA-708 closed captions is crucial for maintaining accessibility and regulatory compliance. This article provides a straightforward guide on how to carry over, copy, and write CEA-708 captions during the transcoding process, ensuring your subtitle data remains intact in the output file whether it is embedded in the video stream or stored as a separate track.

Preserving Embedded CEA-708 Captions (A53 Data)

In many broadcast formats, CEA-708 captions are embedded directly inside the video stream as A53 user data. When you transcode the video (for example, re-encoding from MPEG-2 to H.264 or H.265), this metadata can be discarded by default.

To preserve embedded captions when transcoding using the libx264 or libx265 encoders, you must enable the -a53cc flag.

Command Example:

ffmpeg -i input.mp4 -c:v libx264 -a53cc 1 -c:a copy output.mp4

Preserving Captions as a Separate Subtitle Stream

If your CEA-708 captions are stored as a dedicated subtitle track within a container (such as an MXF or MKV file) rather than embedded in the video packets, you must ensure FFmpeg maps and copies that stream to the output.

Command Example:

ffmpeg -i input.mxf -map 0 -c:v libx264 -c:a copy -c:s copy output.mkv

Verifying the Output

To confirm that the CEA-708 captions were successfully preserved in the transcoded file, use ffprobe to inspect the streams:

ffprobe -loglevel error -show_entries stream=codec_name,properties -of default=noprint_wrappers=1 output.mp4

Look for the presence of a subtitle stream, or check if the video stream properties indicate the presence of closed captions. Alternatively, you can play the output video in a media player like VLC and check the subtitle menu to verify the captions display correctly.