Education

How to Add Subtitles with FFmpeg (Command-Line Guide)

by David Nguyen 12 min read
In this article

Adding subtitles to video shouldn’t require a degree in computer science—but it often feels that way when you’re staring at a command-line terminal for the first time. FFmpeg, the free, open-source video processing tool, offers powerful subtitle capabilities without software licensing fees. Whether you need to burn captions directly into your footage or embed toggleable subtitle tracks, FFmpeg handles both with a few well-crafted commands. For those who prefer skipping the command line entirely, automated subtitles tools can transform a manual workflow into a few clicks—but understanding FFmpeg gives you complete control over subtitle embedding and rendering.

Key Takeaways

  • FFmpeg supports two subtitle methods: soft subtitles, which are toggleable tracks, and hard subtitles, which are permanently burned into the video
  • SRT files use simple timestamp formatting, while ASS/SSA files enable advanced styling with fonts, colors, positioning, and effects
  • Hard-subtitle processing requires video re-encoding, which is slower and more CPU-intensive
  • Soft subtitles can often be added while copying the original video and audio streams, avoiding video re-encoding
  • FFmpeg 8.0 introduced an optional Whisper audio filter for automatic transcription, but availability depends on how the FFmpeg binary was compiled and requires a compatible model
  • SRT offers broad compatibility across subtitle tools, players, and platforms
  • ASS/SSA files provide extensive styling control, including animated text effects and karaoke-style highlighting
  • Soft subtitles can preserve the original video quality when the video stream is copied without re-encoding

Understanding Subtitle Formats: SRT, VTT, and ASS/SSA

Before diving into FFmpeg commands, you need to understand what you’re working with. Subtitle files come in several formats, each serving different purposes and offering varying levels of control.

What Is an SRT File?

SRT, or SubRip Text, remains one of the most widely used subtitle formats due to its simplicity. The structure follows a straightforward pattern:

1

00:00:01,000 –> 00:00:03,500

This is the first subtitle.

2

00:00:03,500 –> 00:00:06,000

This is the second subtitle.

Each entry contains a sequential number, a timestamp range, and the displayed text. You can create and edit SRT files in any text editor—Notepad, TextEdit, or VS Code all work. The format supports basic line breaks but has limited native styling capabilities.

The format you choose affects what’s possible with your subtitles:

  • SRT (SubRip): Plain text with timestamps, broad compatibility, and limited styling
  • VTT (WebVTT): A web-focused format with cue settings and basic styling, commonly used with HTML5 video players
  • ASS/SSA (Advanced SubStation Alpha): Extensive styling control, including fonts, colors, positioning, shadows, and animations

For social media content requiring branded captions, ASS files offer the flexibility to match your visual identity. For accessibility workflows and broad compatibility, SRT is often a practical choice.

Setting Up FFmpeg: Installation and Basic Usage

FFmpeg runs from the command line, meaning you’ll type commands in Terminal on macOS or Linux, or Command Prompt or PowerShell on Windows. Installation varies by operating system:

Windows: Visit the FFmpeg download page and follow one of its links to a compatible Windows build. Extract the files, then add the build’s bin folder to your PATH environment variable.

Mac: Open Terminal and run brew install ffmpeg if you use the Homebrew package manager.

Linux: Run sudo apt install ffmpeg on Ubuntu or Debian, or sudo pacman -S ffmpeg on Arch-based distributions.

Verify your installation by typing:

ffmpeg -version

A successful setup displays version and build-configuration information. For burned-in subtitles, check whether the configuration includes –enable-libass, or run ffmpeg -filters and confirm that the subtitles filter is listed.

Basic FFmpeg Command Structure

Every FFmpeg command follows a consistent pattern:

ffmpeg -i input.mp4 [options] output.mp4

The -i flag specifies your input file, options modify the processing, and the final argument names your output file. Understanding this structure makes even complex commands easier to read.

Soft Subtitles: Adding External Subtitle Tracks to Video

Soft subtitles are stored as separate tracks within a video file, allowing viewers to toggle them on or off. This approach can preserve the original video quality because the video stream does not need to be re-encoded.

Integrating SRT Files Without Re-encoding Video

A basic soft-subtitle command for MP4 is:

ffmpeg -i video.mp4 -i subtitles.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4

Breaking this down:

  • -i video.mp4: Your source video
  • -i subtitles.srt: Your subtitle file
  • -c copy: Copy compatible input streams without re-encoding them
  • -c:s mov_text: Convert the subtitle track to the MP4-compatible mov_text format
  • -metadata:s:s:0 language=eng: Tag the first subtitle track as English

Processing is usually much faster than hard-subtitle rendering because FFmpeg can copy the video and audio streams while converting only the subtitle stream. For teams that need to create subtitle files before embedding them, Sonix can automatically generate SRT files from audio or video.

Handling Multiple Subtitle Languages

For content requiring multiple language options:

ffmpeg -i video.mp4 -i english.srt -i spanish.srt -map 0 -map 1 -map 2 -c copy -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=spa output.mp4

This creates a single video file with selectable English and Spanish subtitle tracks. The -map options explicitly include the streams from each input.

Hardcoding Subtitles: Burning Subtitles Directly into Video

Hard subtitles become permanent parts of the video frames, appearing regardless of player settings. This can help guarantee that captions remain visible in delivery environments that do not reliably display separate subtitle tracks.

Using the Subtitles Filter for Permanent Captions

The basic burn-in command is:

ffmpeg -i video.mp4 -vf “subtitles=subtitles.srt” -c:v libx264 -c:a copy output.mp4

The -vf video-filter option applies the subtitles filter, rendering text directly onto the video frames. Because the filter operates on decoded frames, the video must be re-encoded. The -c:a copy option preserves the original audio stream when it is compatible with the output container.

Customizing Subtitle Appearance

Plain white text does not always match professional video aesthetics. FFmpeg’s force_style option lets you override ASS styling properties:

ffmpeg -i video.mp4 -vf “subtitles=subtitles.srt:force_style=’FontName=Roboto,FontSize=18,BackColour=&H40000000,BorderStyle=3′” -c:v libx264 -c:a copy output.mp4

This creates captions with a partially transparent background. Available styling options include:

  • FontName: An available font name
  • FontSize: An ASS font-size value; the rendered size depends on subtitle and video scaling
  • PrimaryColour: Text color in ASS &HAABBGGRR notation
  • BackColour: Background or shadow color, including alpha
  • BorderStyle: Commonly 1 for an outline or 3 for a boxed background
  • Outline: Outline width in ASS script units
  • Shadow: Shadow depth in ASS script units

Font availability depends on the system and FFmpeg build. For portable workflows, you may need to provide a font directory through the filter’s fontsdir option.

Common Issues and Troubleshooting

Several problems frequently trip up FFmpeg beginners:

“No such filter: subtitles”: Your FFmpeg build may lack libass support. Check ffmpeg -filters, install a build that includes the filter, or compile FFmpeg with –enable-libass.

Garbled characters: The subtitle file may use the wrong character encoding. Re-save it as UTF-8. When working with another encoding, use the subtitles filter’s charenc option where supported.

Subtitles out of sync: Use -itsoffset before the subtitle input to shift the entire subtitle stream. Positive values delay subtitles; negative values advance them.

Massive output file size: Hard subtitles force video re-encoding. For H.264 output, control quality and size with a CRF-capable encoder, such as -c:v libx264 -crf 23. Lower CRF values generally produce higher quality and larger files.

Specific FFmpeg Command Examples for Common Scenarios

Adding SRT to MP4 Video (Soft)

ffmpeg -i interview.mp4 -i captions.srt -c copy -c:s mov_text output.mp4

Use this for players and distribution workflows that support selectable subtitle tracks inside MP4 files. For platforms that provide a dedicated caption-upload interface, uploading the SRT separately may be more dependable.

Burning VTT into MKV Video (Hard)

ffmpeg -i webinar.mkv -vf “subtitles=captions.vtt” -c:v libx264 -c:a copy output.mkv

The -c:a copy option preserves the original audio without re-encoding when the codec is compatible with the output container.

Styled Captions for Social Media

ffmpeg -i clip.mp4 -vf “subtitles=captions.srt:force_style=’FontName=Arial,FontSize=24,PrimaryColour=&H00FFFFFF,BackColour=&H80000000,BorderStyle=3,Alignment=2′” -c:v libx264 -preset veryfast -c:a copy output.mp4

Alignment=2 positions subtitles at the bottom center under standard ASS alignment rules. The -preset veryfast option speeds up libx264 encoding at the cost of some compression efficiency.

Advanced FFmpeg Subtitle Techniques

Adjusting Subtitle Timing

When subtitles don’t match the audio perfectly:

ffmpeg -i video.mp4 -itsoffset 2.5 -i subtitles.srt -c copy -c:s mov_text output.mp4

This delays the subtitle stream by 2.5 seconds. To advance it, use a negative value such as -itsoffset -1.5.

Leveraging ASS for Advanced Visual Effects

ASS files unlock capabilities that plain SRT files do not natively provide:

  • Animated text effects such as fades and movement
  • Karaoke-style highlighting
  • Multiple simultaneous text positions
  • Per-character or per-word styling

Create ASS files using a subtitle-authoring tool, then apply them with FFmpeg’s ASS filter:

ffmpeg -i video.mp4 -vf “ass=styled_captions.ass” -c:v libx264 -c:a copy output.mp4

Generating Subtitles with FFmpeg’s Whisper Filter

FFmpeg 8.0 introduced an optional Whisper audio filter that can generate transcription output, including subtitle files. However, not every FFmpeg 8.x binary includes it.

First, check whether your build provides the filter:

ffmpeg -filters | grep whisper

On Windows PowerShell, you can use:

ffmpeg -filters | Select-String whisper

You will also need a compatible Whisper model file. A representative command structure is:

ffmpeg -i input.mp4 -af “whisper=model=/path/to/model.bin:language=auto:destination=output.srt:format=srt” -f null –

Exact options can vary by FFmpeg version and build. Compatible builds may use supported GPU backends, but acceleration depends on the linked Whisper library, available hardware, drivers, and build configuration.

The filter can create a starting transcript, but accuracy varies with the model, language, accents, recording quality, background noise, and vocabulary. Always review automatically generated subtitles before publication.

FFmpeg and Video Editing Software: Bridging the Gap

FFmpeg excels at batch processing and automation, while dedicated editors offer visual precision. The sweet spot often involves both tools.

When to Use FFmpeg vs. Dedicated Video Editors

Choose FFmpeg when:

  • Processing dozens or hundreds of videos
  • Running automated batch jobs
  • Adding subtitles through repeatable scripts
  • Working in CI/CD pipelines or server environments

Choose video editing software when:

  • Fine-tuning individual subtitle timing visually
  • Creating complex animated captions
  • Working on productions requiring frame-specific placement
  • Needing a real-time visual preview during subtitle adjustments

Exporting FFmpeg-Generated Subtitles for NLEs

FFmpeg can extract or convert a compatible embedded text-subtitle stream:

ffmpeg -i video.mp4 -map 0:s:0 subtitles.srt

This selects the first subtitle stream and converts it to SRT when the source subtitle type can be represented as text. Image-based subtitle tracks cannot be converted directly to SRT without text recognition. The resulting file can be edited in another subtitle tool or incorporated into a broader video workflow.

Streamlining Subtitle Workflows with Sonix

Command-line tools offer power and flexibility, but they demand technical comfort that not everyone has or wants to develop. When deadlines loom and accuracy matters, manual transcription, subtitle timing, and file management can become bottlenecks.

Sonix approaches the subtitle workflow differently by using AI and browser-based tools for the steps that happen before final encoding:

  • Automatic transcription converts audio and video into editable, timestamped text
  • Multi-language support provides transcription in 54+ languages
  • Browser-based editing combines synchronized playback with text and subtitle-timing controls
  • Subtitle export includes SRT, VTT, TTML, FCPXML, and other supported production formats
  • Speaker identification automatically labels different speakers in supported transcription workflows

Sonix officially states that subtitle generation generally takes about five minutes per hour of video, although actual processing time can vary. Its subtitle tools also support timing adjustments, styling, and burned-in caption output.

For teams processing regular content volumes, Sonix’s collaboration features provide shared folders, view and edit permissions, paragraph-level notes, version history, and organized handoffs. Sonix uses a focused editing model in which one person edits while others can view, listen, search, and leave notes.

Sonix is also SOC 2 Type II certified, with data encrypted in transit using TLS and at rest using AES-256. Organizations handling regulated material should still evaluate the specific product, plan, configuration, and contractual requirements that apply to their use case.

FFmpeg remains excellent for final embedding, conversion, and rendering. For the earlier stages—transcription, review, translation, and collaboration—a browser-based platform can reduce the amount of manual file preparation.

Final Verdict: Choosing Between FFmpeg and Professional Transcription Platforms

The decision between FFmpeg and a dedicated transcription platform depends on your workflow requirements and technical comfort level.

Choose FFmpeg when you need:

  • Detailed control over subtitle encoding and rendering parameters
  • Batch processing for automated video pipelines
  • Integration with existing command-line workflows
  • An open-source tool without recurring software subscription fees
  • Scriptable and repeatable media-processing steps

Choose a professional transcription platform when you need:

  • Automatic speech-to-text conversion without creating the transcript manually
  • Browser-based editing with synchronized playback
  • Multi-language transcription and translation
  • Team collaboration and review workflows
  • Speaker identification and labeling
  • Documented security and administrative features

For many content teams, a practical workflow combines both: use Sonix to generate and review timestamped transcripts with speaker labels and collaboration tools, then use FFmpeg to embed or burn the subtitles into final video deliverables. This approach combines an assisted transcription workflow with technical control over the final output.

Frequently Asked Questions

What is the difference between soft and hard subtitles?

Soft subtitles are stored as separate tracks that viewers can toggle on or off through compatible media-player settings. Hard subtitles are rendered permanently into the video frames and appear regardless of subtitle-track support. Soft subtitles can preserve the original video stream when added without re-encoding, while hard subtitles require video re-encoding.

Can FFmpeg automatically generate subtitles from audio?

FFmpeg 8.0 introduced an optional Whisper audio filter for speech-to-text transcription, but the feature is only available in binaries compiled with Whisper support and requires a compatible model file. Some builds can use supported GPU backends, although hardware acceleration is not guaranteed. Accuracy varies with the selected model, language, audio quality, accents, noise, and vocabulary, and the standard filter output does not document the same speaker-identification workflow offered by dedicated transcription platforms.

How can I change the font or color of burned-in subtitles with FFmpeg?

Use the force_style option within the subtitles filter. For example, -vf “subtitles=captions.srt:force_style=’FontName=Arial,FontSize=20,PrimaryColour=&H0000FFFF'” applies Arial text with an ASS color value. ASS colors use &HAABBGGRR notation, where AA represents alpha. You can also specify BackColour, BorderStyle, Outline, Shadow, and alignment properties.

What subtitle formats does FFmpeg support?

FFmpeg can read, write, convert, or process many subtitle formats, including SRT, WebVTT, ASS/SSA, and several image-based subtitle formats. Exact support depends on the FFmpeg build, input format, output container, and selected subtitle codec. For soft subtitles in MP4, -c:s mov_text is commonly used. Matroska containers can store text codecs such as SRT and ASS more directly, while hard-subtitle workflows commonly use the subtitles or ass filters for supported text formats.

How do I ensure my subtitles are perfectly synchronized with my video?

Preview short segments before processing the entire video. If the complete subtitle track appears consistently early or late, place -itsoffset before the subtitle input: positive values delay the track, while negative values advance it. For problems affecting only individual lines, edit the timestamps in the subtitle file or use a visual subtitle editor with waveform and playback controls.

Get accurate transcription in minutes

Start transcribing smarter. Try Sonix free or explore our pricing to find the right plan for you.