Short answer: to flip a video with FFmpeg, re-encode through hflip or vflip:
ffmpeg -i input.mp4 -vf hflip -c:v libx264 -pix_fmt yuv420p -c:a copy flipped.mp4
hflip is a left–right mirror. vflip is a top–bottom mirror. The frame size stays the same (here, 720×1280). That is not a rotate: transpose=1 would turn this clip into 1280×720. And despite what autocomplete offers for "ffmpeg flip video without re encoding", a flip is a video filter, so -c:v copy is rejected: Filtering and streamcopy cannot be used together. Audio can still be stream-copied. Below are pixel-exact measurements on a real 8-second clip, a small Python module, and five pytest checks.
The test clip
The fixture is a real generated example from Voor's Enzo Fernandez Celebration page: a vertical 720×1280 H.264 + AAC clip, 24 fps, 193 frames, 8.041667 s, with stadium crowd sound. MD5 of the file is 3f8a3a6abc3da386c4d6628e6ff56ff9.
curl -O https://cdn.voor.ai/voor/keyword-landing/enzo-fernandez-celebration/v20261019/touchline-blue-v2.mp4
ffprobe -v error -show_entries stream=codec_name,width,height,nb_frames,sample_rate -count_frames \
-of default=nw=1 touchline-blue-v2.mp4
# width=720
# height=1280
# nb_frames=193
# codec_name=h264
# codec_name=aac
# sample_rate=44100
(Tested with FFmpeg 9.0.1, Python 3.13, pytest 9.2.0.)
Mistake 1: treating a flip as a rotate
ffmpeg flip video 90 degrees shows up in US-English autocomplete next to the horizontal/vertical queries. A 90° rotate changes the axes. A flip does not.
ffmpeg -i touchline-blue-v2.mp4 -vf hflip -frames:v 1 -f rawvideo -pix_fmt rgb24 hflip.rgb
ffmpeg -i touchline-blue-v2.mp4 -vf transpose=1 -frames:v 1 -f null -
The first command still writes a 720×1280 frame. transpose=1 would write 1280×720. On the raw RGB24 first frame, hflip is exactly the Python left–right mirror of the source — every row reversed, zero differing bytes. vflip is exactly the top–bottom mirror. If you wanted the clip upside down and backwards left-to-right, that is hflip,vflip, and it is byte-identical to rotate=PI (a 180° rotate). It is not a 90° rotate.
Mistake 2: expecting a flip without re-encoding
"ffmpeg flip video without re encoding" is a real autocomplete suggestion. This is what FFmpeg 9.0.1 does with it:
ffmpeg -i touchline-blue-v2.mp4 -vf hflip -c:v copy -c:a copy copy.mp4
# Filtergraph 'hflip' was specified, but codec copy was selected.
# Filtering and streamcopy cannot be used together.
# Error opening output files: Invalid argument
The process exits non-zero (234 here) and writes no file. A horizontal flip has to rewrite every macroblock; the original bitstream cannot be copied. There is no lossless -c:v copy path for hflip or vflip. If you only needed to tag a player to mirror at display time, that would be a different (and poorly supported) metadata trick — and it would not change the pixels, which is what a flip is supposed to do.
Mistake 3: re-encoding the audio when you only flipped the picture
The video has to be re-encoded. The audio does not. With -c:a copy the AAC bitstream is identical to the source: MD5 5843435af71daac1e832f8b54fe25bdf on both the original and the flipped file, 131354 bytes. You keep the stadium crowd exactly as it was, and you do not pay a second AAC encode.
Flipping twice is also exact on the raw frame: hflip,hflip returns the original 720×1280 RGB24 first frame with zero differing bytes. That is a useful sanity check before you trust a longer filter chain.
A small module that flips and checks the pixels
flip.py wraps the operations the tests actually use: decode the first frame to raw RGB24 (optionally through a filter), build a Python mirror to compare against, attempt a stream-copy flip (which must fail), and re-encode a flipped file while copying the audio.
"""Flip a video with FFmpeg (hflip/vflip) and prove the pixels actually moved."""
from __future__ import annotations
import json
import subprocess
from pathlib import Path
WIDTH = 720
HEIGHT = 1280
def _run(cmd: list[str], check: bool = True) -> subprocess.CompletedProcess:
return subprocess.run(cmd, check=check, capture_output=True, text=True)
def probe(path: Path) -> dict:
out = _run([
"ffprobe", "-v", "error", "-count_frames", "-show_entries",
"format=duration,size:stream=codec_name,width,height,nb_read_frames,codec_type",
"-of", "json", str(path),
]).stdout
data = json.loads(out)
video = next(s for s in data["streams"] if s["codec_type"] == "video")
audio = next(s for s in data["streams"] if s["codec_type"] == "audio")
return {
"duration": float(data["format"]["duration"]),
"width": int(video["width"]),
"height": int(video["height"]),
"frames": int(video["nb_read_frames"]),
"vcodec": video["codec_name"],
"acodec": audio["codec_name"],
}
def first_frame_rgb_bytes(path: Path, vf: str | None = None) -> bytes:
cmd = ["ffmpeg", "-v", "error", "-i", str(path)]
if vf:
cmd += ["-vf", vf]
cmd += ["-vframes", "1", "-f", "rawvideo", "-pix_fmt", "rgb24", "pipe:1"]
p = subprocess.run(cmd, check=True, capture_output=True)
expected = WIDTH * HEIGHT * 3
if len(p.stdout) != expected:
raise ValueError(f"unexpected frame size {len(p.stdout)}, wanted {expected}")
return p.stdout
def mirror_horizontal(frame: bytes, width: int = WIDTH, height: int = HEIGHT) -> bytes:
out = bytearray(len(frame))
row = width * 3
for y in range(height):
src = memoryview(frame)[y * row:(y + 1) * row]
dest = memoryview(out)[y * row:(y + 1) * row]
for x in range(width):
dest[(width - 1 - x) * 3:(width - x) * 3] = src[x * 3:(x + 1) * 3]
return bytes(out)
def mirror_vertical(frame: bytes, width: int = WIDTH, height: int = HEIGHT) -> bytes:
out = bytearray(len(frame))
row = width * 3
for y in range(height):
out[(height - 1 - y) * row:(height - y) * row] = frame[y * row:(y + 1) * row]
return bytes(out)
def flip(path: Path, vf: str, dest: Path, *, video_copy: bool = False, audio_copy: bool = True) -> subprocess.CompletedProcess:
"""Re-encode (or attempt stream-copy) a flipped file. audio_copy keeps the AAC bitstream."""
dest.parent.mkdir(parents=True, exist_ok=True)
cmd = ["ffmpeg", "-v", "error", "-y", "-i", str(path), "-vf", vf]
if video_copy:
cmd += ["-c:v", "copy"]
else:
cmd += ["-c:v", "libx264", "-pix_fmt", "yuv420p"]
cmd += ["-c:a", "copy" if audio_copy else "aac", str(dest)]
return _run(cmd, check=False)
def extract_audio(path: Path, dest: Path) -> Path:
dest.parent.mkdir(parents=True, exist_ok=True)
_run(["ffmpeg", "-v", "error", "-y", "-i", str(path), "-map", "0:a:0", "-c", "copy", str(dest)])
return dest
Five pytest checks
test_flip.py uses the same fixture. The first four tests decode raw frames, so they are not affected by a later H.264 encode:
def test_hflip_mirrors_each_row_exactly():
src = first_frame_rgb_bytes(SRC)
flipped = first_frame_rgb_bytes(SRC, "hflip")
assert flipped == mirror_horizontal(src, WIDTH, 1280)
assert flipped != src
def test_vflip_mirrors_top_to_bottom_exactly():
src = first_frame_rgb_bytes(SRC)
flipped = first_frame_rgb_bytes(SRC, "vflip")
assert flipped == mirror_vertical(src, WIDTH, 1280)
assert flipped != src
def test_hflip_twice_returns_the_original_frame():
src = first_frame_rgb_bytes(SRC)
assert first_frame_rgb_bytes(SRC, "hflip,hflip") == src
def test_hflip_and_vflip_equal_a_180_degree_rotate():
both = first_frame_rgb_bytes(SRC, "hflip,vflip")
rotated = first_frame_rgb_bytes(SRC, "rotate=PI")
assert both == rotated
def test_filter_cannot_stream_copy_but_audio_copy_is_lossless(tmp_path):
refused = flip(SRC, "hflip", tmp_path / "copy.mp4", video_copy=True)
assert refused.returncode != 0
assert "Filtering and streamcopy cannot be used together" in (refused.stderr or "")
dest = tmp_path / "hflip.mp4"
ok = flip(SRC, "hflip", dest, video_copy=False, audio_copy=True)
assert ok.returncode == 0
info = probe(dest)
assert info["width"] == 720 and info["height"] == 1280
assert info["frames"] == 193
assert info["acodec"] == "aac"
src_a = extract_audio(SRC, tmp_path / "src.aac")
dst_a = extract_audio(dest, tmp_path / "dst.aac")
assert hashlib.md5(dst_a.read_bytes()).hexdigest() == hashlib.md5(src_a.read_bytes()).hexdigest()
assert hashlib.md5(src_a.read_bytes()).hexdigest() == "5843435af71daac1e832f8b54fe25bdf"
uvx --python 3.13 pytest -v test_flip.py
# 5 passed in 1.26s
Where the fixture came from
The clip is a real Enzo Fernandez Celebration example generated on Voor: one photo becomes an 8-second 9:16 run to the corner flag, hands behind the ears, stadium crowd included. With the official published input still in the form, the generator quoted 469 credits for a public, watermarked clip on November 16, 2026. If you want your own clip to practice on, the Enzo Fernandez Celebration generator is where this one came from — then flip it with the commands above. (The page is an independent trend tool, not affiliated with Enzo Fernández or any club or broadcaster. Use a photo of yourself, a pet, or someone who agreed.)


Top comments (0)