Subtitles with FFmpeg: Burn‑In, Soft Subs, and Format Conversion
Wed Jun 05 2024
Burn SRT into video, add soft subtitles, and convert between SRT, VTT, and mov_text for MP4.
FFmpeg can embed, burn, and convert subtitles. Use burn‑in when you need captions visible everywhere; use soft subs to keep tracks switchable.
Subtitle Types
- SRT: common text format; simple styling.
- ASS: advanced styling.
- VTT: web‑friendly.
- Embedded: tracks stored inside containers like MP4/MKV.
Workflows
# Burn-in SRT ffmpeg -i video.mp4 -vf "subtitles=subs.srt" -c:v libx264 -crf 22 -c:a copy out_burn.mp4 # Add soft subs to MP4 (convert to mov_text) ffmpeg -i video.mp4 -i subs.srt -c copy -c:s mov_text out_soft.mp4 # Convert SRT → WebVTT ffmpeg -i subs.srt subs.vtt # Extract first subtitle stream from MKV as SRT ffmpeg -i in.mkv -map 0:s:0 -c:s srt subs.srt
Pitfalls
- MP4 stores text subs as
mov_text; SRT isn’t valid in MP4. - Non‑UTF‑8 files may require
-sub_charenc UTF-8.
Pick burn‑in when compatibility is critical; prefer soft subs when you want multiple languages or editability.