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

bbb ffmpeg-user at bugblatterbeast.de
Sat Dec 16 18:34:11 EET 2023

On 12/16/23 14:26, bbb wrote:
> 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
It is very strange. Even though the result looks perfect in an editor 
(subtitle composer). Some of the subtitle events neither show on TV nor 
on vlc.

This also happens, when I just export and the re-import the ssa 
subtitles without editing them.

ffmpeg -i video-input.mkv -map 0:s:0 -c copy temp.ssa
ffmpeg -i video-input.mkv -i temp.ssa -map 0 -map 1 -c copy video-result.mkv

All the subtitle events without a pause in between (current starttime = 
previous endtime or current endtime = next starttime) are not showing 
(option -fix_sub_duration doesn't make a difference).

More information about the ffmpeg-user mailing list