brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -c:s mov_text adds subtitles to an MP4 that you can switch off

Ffmpeg
~/tips/tip-ffmpeg-mov-text-soft-subs

ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4

Puts an SRT file into an MP4 as a subtitle track instead of burning it into the picture.

Burning subtitles into the picture is permanent. For subtitles that can be switched on and off, add them as a separate track.

ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4

The SRT file is a second input, and -map 1 adds it to the output. -c copy copies video and audio untouched and -c:s mov_text converts the subtitles to the text format MP4 supports. That last part is required: MP4 can’t hold SRT directly, and without mov_text the command stops with an error. The language tag helps players show a proper name in their menu.

For MKV it’s even simpler, because MKV stores SRT as it is: same command, an .mkv output, and -c:s srt or just -c copy.

A limit of mov_text is styling. Colors, positions and fonts from an ASS file mostly get lost. For anime or karaoke subtitles with fancy styling I’d stay with MKV. Also, some players, especially smart TV apps, ignore subtitle tracks in MP4. When that matters, test the file on the device before converting a whole folder.

Further reading: ffmpeg documentation, FFmpeg formats documentation

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a ffmpeg -n -i "$f" -c copy "${f%.mkv}.mp4" All Ffmpeg tips (38) All topics

Link