[FFmpeg-user] Strip all formatted entries from an ssa or srt stream

bbb ffmpeg-user at bugblatterbeast.de
Sat Dec 16 15:26:45 EET 2023


On 12/16/23 02:59, bbb wrote:
> Hi,
>
> I'm still improving my automatically added fallback subtitle stream. 
> My TV doesn't cope well with formatted or positioned entries. They 
> just result in a bunch of numbers and codes that fill the entire 
> screen so that no meaningful part of the subtitles is visible any 
> more. All those subtitle creators who mean well by translating signs 
> in place or trying to sync the colour of some song lyrics are making 
> it a pain for me to watch those subtitles on my TV.
>
> I would like to be able to strip all formatted or positioned parts of 
> the subtitles, so that only the speech translations remain. I already 
> have an idea how to approach that, but I thought maybe somebody 
> already come up with a solution that I can use or adapt.
>
>  Kind regards,
> Nils

Well, I am super lazy. Here is a very effortless solution to this 
problem using ssa subtitles:

cat exported.ssa | grep -v -E "(pos\(\-?[0-9]*(\.[0-9]*)?, 
?\-?[0-9]*(\.[0-9]*)?\)|move\(\-?[0-9]*(\.[0-9]*)?(, 
?\-?[0-9]*(\.[0-9]*)?)*\))" > stripped.ssa

I couldn't think of an easy way to remove all formats while keeping the 
file intact. Also I figured, that the formats aren't the problem - my TV 
just ignores them. I decided to just strip all lines that include 
override code "pos" or "move". So far this worked fine for all the 
subtitles I've tested.

I'm good with that for now (haven't finished testing though). Still, I'd 
appreciate any suggestions for improvement.

Kind regards,
Nils



More information about the ffmpeg-user mailing list