Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretch Subtitles Timing by Factor

Tags:

video

ffmpeg

I'm muxing an mkv video, but the Subtitle .ssa file is out of sync by around 1 second by the end of the video.

Delaying the subtitles by 1 second in the beginning is not enough, the timing needs to be stretched to fix an exponentially growing delay. Sync starts out fine in the beginning, but a few milliseconds delay multiplies for each minute that passes.

I fixed them using MKVToolNix with Stretch 0.999.


How can I stretch Subtitles using FFmpeg?

I saw here how to stretch audio by a factor the same way. ffmpeg, stretch audio to x seconds

I'm using something like this:

ffmpeg -y 

-fflags +genpts 

-i "video.m4v"  
-i "audio.ac3" 
-i "subs.ssa" 

-c:v copy 
-c:a copy 
-c:s copy 

-map 0:v? 
-map 1:a? 
-map 2:s?

"video.mkv"

I used -itsoffset -00:00:01.000 to remove a gap in the beginning, but it does not stretch.

like image 208
Matt McManis Avatar asked May 09 '26 20:05

Matt McManis


1 Answers

You can achieve this with -itsscale:

ffmpeg -itsscale <factor> -i input.srt output.srt

I don’t know when it was introduced but it sits just below -itsoffset in the man page.

like image 92
Idl Avatar answered May 11 '26 15:05

Idl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!