Tony Tascioglu Wiki

TechnoTony Wiki - Tony Tascioglu's personal public knowledge-base!

User Tools

Site Tools


scripts:ffmpeg:extract_closed_captions_to_subtitles

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scripts:ffmpeg:extract_closed_captions_to_subtitles [2022-04-06 21:45] – created Tonyscripts:ffmpeg:extract_closed_captions_to_subtitles [2025-05-31 22:25] (current) Tony
Line 1: Line 1:
 +====== Extract line 21 / EIA 608 closed captions to subtitle files ======
 +
 +**NOTE:** If you are coming here from the Technology Connections video on DVD closed captions, this method will work! Once you convert closed captions to subtitles, it works much better in players!
 + **BUT WAIT - THERE'S MORE!** If you save to ass/ssa or advanced formats, the position and color information will be retained!
 +
 +Some MP4 and ts files have closed captions embedded in the old ATSC standard. Some players can't handle embedded closed captions, and it's more convenient to have it as a separate file.
 +
 +You can extract the CC streams and save it as a separate file as follows:
 +
 +<code>
 +ffmpeg -f lavfi -i "movie='input.mp4'[out0+subcc]" -map s "output.ssa";
 +
 +</code>
 +
 +where input and output are the filenames to use. Subrip SRT files can be used for the output instead of SubStationAlpha SSA files. SSA seems to actually decode the proper colours and location of the closed captions better, and maintains that information although it is less compatible with some players.
 +
 +You can easily make this loop across a folder with a for loop.
 +
 +<code>
 +for i in *.mp4;
 + do name=`echo $i | cut -d'.' -f1`;
 + ffmpeg -f lavfi -i "movie='$i'[out0+subcc]" -map s "${name}.ssa";
 +done
 +
 +</code>