Skip to content

Instantly share code, notes, and snippets.

@souhaibdjaballah
Last active March 2, 2023 22:57
Show Gist options
  • Save souhaibdjaballah/91f7f0879237b1aa585dac390e1572a2 to your computer and use it in GitHub Desktop.
Save souhaibdjaballah/91f7f0879237b1aa585dac390e1572a2 to your computer and use it in GitHub Desktop.

A fast way to split both a video and its subtitle then integrate the subtitle back into the new segment

Segment video file

(sometimes you may encounter a weird behavious where the output video starts before 5 seconds than specified in the -ss parameter)

ffmpeg -ss 00:00:14.500 -i input.mp4 -t 00:17:05.500 -c copy d:\_ffmpeg_output\output.mp4

or use the -copyts and -to paramaters

ffmpeg -ss 00:00:14.500 -copyts -i input.mp4 -to 00:17:20.0 -c copy d:\_ffmpeg_output\output.mp4

Segment subtitle file

ffmpeg -ss 00:00:14.500 -i input.srt -t 00:17:05.500 d:\_ffmpeg_output\output.srt

Integrating a subtitle file into a video without encoding (soft subtitle) - Fast method

ffmpeg -i output003.mp4 -i output003.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng ouptut_soft.mp4


Using .ass format

ffmpeg -i subtitle.srt d:\_ffmpeg_output\subtitle.ass

ffmpeg -ss 00:17:15.0 -i subtitle.ass -t 00:15:18.0 d:\_ffmpeg_output\part001-sub.ass

If you need encoding use this format

ffmpeg -sub_charenc WINDOWS-1256 -i subtitle.srt d:\_ffmpeg_output\output_win.ass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment