Flip Video and Keep Subtitles in FFmpeg
This article explains how to use FFmpeg to flip a video horizontally or vertically while keeping your subtitles readable, correctly positioned, and in their original orientation. Depending on whether you are burning the subtitles directly into the video (hardcoding) or keeping them as a selectable track (softcoding), you will find the precise commands needed to achieve the correct result.
Method 1: Hardcoding (Burning) Subtitles onto Flipped Video
If you want to burn subtitles directly into the video file so they cannot be turned off, you must chain the video filters in a specific order. You must apply the flip filter before applying the subtitle filter. If you burn the subtitles first and then flip the video, the text will be mirrored and unreadable.
To flip horizontally (mirror image) and burn subtitles:
ffmpeg -i input.mp4 -vf "hflip,subtitles=subs.srt" -c:a copy output.mp4To flip vertically (upside down) and burn subtitles:
ffmpeg -i input.mp4 -vf "vflip,subtitles=subs.srt" -c:a copy output.mp4By placing hflip or vflip before
subtitles in the filtergraph (separated by a comma), FFmpeg
flips the video frame first, and then renders the text upright and in
the correct left-to-right reading order on top of the flipped image.
Method 2: Soft Subtitles (Selectable Tracks)
If your input video has selectable soft subtitles (like an SRT or ASS stream) and you want to keep them as soft subtitles in the output, you only need to flip the video stream and copy the subtitle stream. Media players will render the subtitle stream on top of the video in the correct, unflipped orientation automatically.
To flip the video and copy the soft subtitle stream:
ffmpeg -i input.mkv -vf "hflip" -c:v libx264 -c:a copy -c:s copy output.mkvIn this command: * -vf "hflip" flips the video track. *
-c:s copy copies the subtitle track without altering its
text or positioning data. * -c:a copy copies the audio
without re-encoding to save time.