How to Flip a Video Horizontally with FFmpeg
To flip a video horizontally with FFmpeg, add -vf hflip and re-encode. This is useful when you want a video recorded with a phone's front camera to match the mirror view, or when you want to watch a dance routine facing the same way as a mirror.
If you want to avoid re-encoding, you can use -display_hflip instead. It adds only the information that the video should be flipped horizontally on display. In my test environment, adding this information to a 60-second video finished without encoding, and the video data stayed exactly the same as in the original file.
My test environment was Ubuntu 24.04.5, FFmpeg 6.1.1 (Ubuntu package 6.1.1-3ubuntu5), on a virtual machine with 4 CPU cores. The source video was a 60-second MP4 (1280×720, 30fps, H.264, AAC audio) made from FFmpeg's testsrc2 test pattern with the text "ABC 123" drawn on it. I checked playback only in Chromium 158, run through Playwright. I did not test smartphone-recorded videos, players such as VLC, or display on video sharing services.
- 1. Flipping the video itself with hflip
- 2. Processing time and quality
- 3. hflip cannot be used with -c copy
- 4. Adding only the flip information with -display_hflip
- 5. Don't add hflip on top of a video that already has the flip information
- 6. Vertical flip and 180-degree rotation
- 7. Flipping only part of the video by time
Flipping the video itself with hflip
The command to flip the video horizontally is:
ffmpeg -i src.mp4 -vf hflip -c:a copy hflip.mp4
The hflip filter flips the video horizontally. -c:a copy copies the audio without re-encoding it.

As the image shows, "ABC 123", which was at the upper left, moved to the upper right and appeared mirrored. Any text in the video is also turned so that it cannot be read normally.
These are the RGB values of the pixels at the upper left and upper right, compared in the first frame.
src.mp4 x=0 y=0: 129 0 255
src.mp4 x=1279 y=0: 0 255 255
hflip.mp4 x=0 y=0: 0 255 255
hflip.mp4 x=1279 y=0: 136 0 255
The color at the right edge of the original is now at the left edge, and the color at the left edge is now at the right edge. The original left-edge value 129 0 255 shows up as 136 0 255 at the right edge after flipping. This small difference comes from re-encoding. As I describe below, the values do not change if no encoding step is involved.
The output video was 1280×720, 30fps, 1800 frames, 60.000 seconds, the same as the original. The audio data has the same hash (MD5) as the original video, so it was not changed.
Processing time and quality
Adding hflip means the video is re-encoded, so the processing time is about the same as a re-encode. I compared a 60-second video encoded with and without the filter. Both used libx264 with default settings.
| Options | Time taken | File size |
|---|---|---|
-vf hflip -c:a copy |
15.1 seconds | 20,648,753 bytes |
No filter, -c:a copy |
14.0 seconds | 20,370,777 bytes |
The difference from the run without the filter was 1.1 seconds (each value is from a single run).
Quality drops by the amount that re-encoding loses. I used the original video flipped with hflip as the reference and compared the output using PSNR. The average was 44.87 dB. PSNR measures the difference between two videos, and identical videos give inf.
Flipping itself only rearranges pixels. A video with hflip applied twice, without any encoding step, had a hash that matched the original exactly.
$ ffmpeg -v error -i src.mp4 -map 0:v -f md5 -; ffmpeg -v error -i src.mp4 -map 0:v -vf hflip,hflip -f md5 -
MD5=75afb35399ada6db177f92b50f36f8bb
MD5=75afb35399ada6db177f92b50f36f8bb
hflip cannot be used with -c copy
If you specify -vf hflip together with -c copy, FFmpeg stops with an error.
Filtergraph 'hflip' was specified, but codec copy was selected. Filtering and streamcopy cannot be used together.
The official Streamcopy section also explains that filters work on decoded frames, so they cannot be used when a stream is copied as is. Re-encode the video and copy the audio with -c:a copy.
Adding only the flip information with -display_hflip
If you do not want to re-encode, use -display_hflip. This is an input option described in the official Video Options section. It writes the information that the video should be flipped horizontally on display (a display matrix) into the file. Because it is an input option, put it before -i.
ffmpeg -display_hflip -i src.mp4 -c copy flag.mp4
The output file was 21,736,904 bytes, the same size as the original. When I extracted the video data and compared hashes, it matched the original video. Only the information attached to the file changed.
ffprobe showed the following information attached to the file.
$ ffprobe -v error -select_streams v -show_entries stream_side_data -of default flag.mp4
[STREAM]
[SIDE_DATA]
side_data_type=Display Matrix
displaymatrix=
00000000: -65536 0 0
00000001: 0 65536 0
00000002: 0 0 1073741824
rotation=-180
[/SIDE_DATA]
[/STREAM]
The output shows rotation=-180, but the video is not rotated 180 degrees. When FFmpeg decodes this file, the video's hash matched the original video with hflip applied. It did not match a 180-degree rotation (hflip,vflip), which also flips vertically. Reading only the rotation value could lead you to think the video is rotated 180 degrees, so check the direction by looking at the decoded video.
The playback in Chromium was also flipped horizontally. I displayed the original video, the video re-encoded with hflip, and the video with -display_hflip in a <video> element, then compared the colors at the upper left and upper right of the screen.
src-chromium.png (5,5): 255 133 10
src-chromium.png (634,5): 0 230 255
hflip-chromium.png (5,5): 0 230 255
hflip-chromium.png (634,5): 255 135 7
flag-chromium.png (5,5): 0 230 255
flag-chromium.png (634,5): 255 133 10
These values are the colors at (5,5) and (634,5) on a screen displayed 640px wide. They differ from the pixel values of the first frame I showed earlier. The video with the flip information was displayed in the same direction as the video re-encoded with hflip.
Don't add hflip on top of a video that already has the flip information
If you re-encode a video that has the -display_hflip information without any filter (I tested the first 5 seconds), FFmpeg flips the video automatically before encoding it. The output has no flip information left, and the upper-left color is 0 255 255, which means the video has been flipped.
The official documentation says this is the work of -autorotate, which is enabled by default. During re-encoding, it rotates the video at the filter stage to match the file's information. If you put -autorotate 0 before the input (the official documentation describes it as -noautorotate), the decoded video matches the original video's hash, and no flip is applied.
If you also add -vf hflip, the flip is applied twice.
ffmpeg -i flag.mp4 -t 5 -vf hflip -c:a copy double.mp4
The upper-left color of this video is 134 0 255, which is close to the upper-left color of the original (129 0 255). In other words, it is back to the unflipped direction. When the flip information and hflip are both applied, the two flips cancel out. Before adding -vf hflip, check whether the file has a Display Matrix by running ffprobe with -show_entries stream_side_data. This makes it clear which flip is in effect.
Vertical flip and 180-degree rotation
The vertical flip is the vflip filter. Applying both hflip and vflip gives the same result as a 180-degree rotation. In my test environment, three combinations produced identical decoded video hashes: hflip,vflip, vflip,hflip, and transpose=clock (rotate 90 degrees clockwise) applied twice.
MD5=cdfdfef86bc0f3e28f75c5f5f8c48c5e
MD5=cdfdfef86bc0f3e28f75c5f5f8c48c5e
MD5=cdfdfef86bc0f3e28f75c5f5f8c48c5e
Flipping only part of the video by time
hflip supports the enable option for timeline editing. If you write an expression in enable, the filter is applied only to frames where the expression is non-zero. The following command flips the video only between 2 and 4 seconds.
ffmpeg -i src.mp4 -t 6 -vf "hflip=enable='between(t,2,4)'" -c:a copy partial.mp4
I compared the upper-left color at 1, 3, and 5 seconds with the original video.
| Time | Upper left of output | Upper left of original | Upper right of original |
|---|---|---|---|
| 1 second | 242 0 0 | 242 0 0 | 0 255 255 |
| 3 seconds | 13 252 231 | 255 0 2 | 10 255 234 |
| 5 seconds | 234 16 0 | 237 16 0 | 0 255 255 |
Only at 3 seconds does the upper-left corner show the color from the original's upper-right corner, so the frame is flipped. At 1 and 5 seconds, the video keeps the same direction as the original.





