I extracted part of a media file using the answer given at FFMpeg : Creating a video clip of approx. 10 seconds when video duration is unknown without audio- . In my case it is an .mkv file. The thing is the media file doesn't have subtitles embedded in it. I do have an external subtitle file. Now I want to mux the subtitle file to the video but only of a very small part.

For e.g. let's say the video file is of 1 hour duration. The extracted video is of 2 minutes or 120 seconds. I know the position of the video as well as well as where it is located in the subtitle (srt) file. My question is how to embed/mux the subtitles which are relevant to only that part of the video file and let it remain as it is. I am guessing ffmpeg would be the answer to it, as it is for many things in manipulating media files.


Use the same command. ffmpeg can also manipulate subtitle. Just replace the video file with subtitle file.

ffmpeg -i "A_File_sub.srt" -ss 00:00:0.0 -t 10 "B_File_sub.srt"

You'll get a synced subtitle file. Then merge it using

ffmpeg -i B_File.mp4 -i B_File_sub.srt -c:v copy -c:a copy -c:s mov_text  B_File_With_srt.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.