← Blog
Two frames at 4.5 seconds show the caption covering the input label in the first export and sitting above it in the revision.
Published on

Burn subtitles into a course video with FFmpeg

To burn subtitles into a video with FFmpeg, give the subtitles filter the reviewed SRT file and encode a new video from the final cut. The words become part of the picture. That suits a course preview that needs to show captions wherever the MP4 plays. Keep the clean master and the selectable caption track for the course platform, where viewers can turn captions on or choose a language.

In our first preview, the line “Check the audio levels.” covered the slide label that told learners which input to check. The words and timing were right. We caught the problem by looking at the exported frame, then rendered a second copy with the line higher on the slide.

Start with a final cut and a reviewed SRT

Download the clean lesson, reviewed SRT, captioned MP4 and proof frames. The 9.72-second example uses a 1280 × 720 slide with a labeled input meter and three lines of synthetic speech. Open lesson-master.mp4 and reviewed.srt from the same folder. If the picture or dialogue has changed since the captions were reviewed, use the subtitle-timing guide to check the cues against the new cut before encoding.

Start with the output brief. This sample calls for one English preview with always-visible captions and the original mono audio. Each extra language or aspect ratio needs its own placement review. A vertical crop can put a caption over something that was clear in the landscape version.

Render the captions into a separate MP4

Use an FFmpeg build with the subtitles filter and the libx264 encoder. Run ffmpeg -filters and look for subtitles. It uses libass to draw text into video frames. The command below uses Arial, which was available on the test machine. If your system substitutes another font, check line wrapping in the export. FFmpeg subtitles filter reference.

From the sample folder, run this as one line. It writes my-preview.mp4, a fresh filename distinct from both the master and the supplied review copy.

ffmpeg -n -i lesson-master.mp4 -map 0:v:0 -map 0:a:0 -vf "subtitles=reviewed.srt:force_style='FontName=Arial,FontSize=21,Outline=2,Shadow=0,Alignment=2,MarginV=64'" -c:v libx264 -crf 18 -preset medium -pix_fmt yuv420p -c:a copy -sn -movflags +faststart my-preview.mp4

The two -map options select the first video and audio streams. The filter changes the picture, so the video must be encoded again. -c:a copy retains this master’s MP4-compatible AAC audio. -sn excludes selectable subtitle streams from the output. The filter still draws the external SRT into the picture. The -n option stops FFmpeg from overwriting an existing file.

Alignment=2 anchors the text at bottom center. MarginV sets the vertical margin in subtitle style units. We raised it from 8 to 64 after inspecting the first render. Those values are specific to this layout. Use the actual slide content to decide where a cue belongs.

Check the exported picture with captions switched off

Open preview-release.mp4 on its own with external subtitles disabled. Our export contains one H.264 video stream and one AAC audio stream. With the captions in the picture, the text remains visible even when the player has no subtitle track selected.

  • 1.0 second, opening. Read “Open the project folder.” Check the final period and leave enough space below the line for the input label.
  • 3.0 seconds, first pause. The opening line has cleared. “INPUT 01 / VOICE” belongs to the slide and stays on screen.
  • 4.5 seconds, correction. Read “Check the audio levels.” In the first export it crossed the input label. In the revised export both lines can be read at once.
  • 6.5 and 8.0 seconds, pause and closing. The caption area is clear at 6.5 seconds. At 8.0 seconds it reads “Save the final recording.”

Compare the frames in playback-proof.png or pause the MP4 at those times. Then play the final file in the intended player with the sound on. Listen for each line against the speech and check that playback controls, cropping and platform re-encoding leave the label readable. If you find a collision, record the cue, timestamp and obscured content so the editor can reproduce it.

Make the weekly handoff

The sample release note records one correction at 4.5 seconds and passes the revised placement. Keep the approved SRT and clean master with the exact MP4 you reviewed. If the wording changes later, edit the SRT, render a new copy and review the affected interval again.

For one preview, a workstation can handle the job. When several lessons need versions before the same deadline, time a CPU encode using a representative lesson at delivery resolution. Count the versions, including any re-renders, and reserve time for playback and corrections. If the renders use up the remaining delivery window, compare that measured queue with the CPU VM buying guide.

We rendered both placements locally with FFmpeg 7.1, compared the decoded audio with the clean master and inspected the revised frames at 400 pixels wide. The audio samples matched. The frame checks cover wording, the two pauses and label clearance. Playback in a course platform, listening on a physical phone and cloud throughput remain untested.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.