How to Fix Upside Down Video Playback Issue with ffmpeg

Abstract: Fix upside down video playback by updating orientation metadata or physically rotating frames with ffmpeg.

Created: 2026-10-23 by
Videos appear upside down because the container stores orientation metadata or pixel data is rotated. Use ffmpeg to correct this by applying a rotation filter or updating the metadata tag directly. This ensures players interpret the video frame correctly without requiring manual user adjustment.

Understanding Video Orientation Metadata

Modern video files often contain an rotate metadata tag that tells compatible players how to orient the image. If this tag is missing, incorrect, or ignored by your playback software, the video will display in its raw, potentially inverted state. The underlying pixel data might be perfectly fine, but the player needs explicit instructions on which way is up. This issue is common with videos captured from smartphones or cameras that automatically rotate footage during recording but fail to update the file header consistently.

Before attempting complex re-encoding, it is crucial to diagnose whether the problem lies in the metadata or the actual pixels. Some players ignore metadata entirely and rely solely on the visual content. In these cases, simply updating the tag will not solve the viewing issue, and you must physically rotate the frames using ffmpeg filters.

Method 1: Updating Metadata Tags

If your video player supports metadata-based rotation, the fastest solution is to write the correct rotation value into the file headers. This method is lossless because it does not re-encode the video stream, preserving original quality and completing almost instantly. You can use the -metadata flag to set the rotate value.

ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=180 output.mp4

In this command, -c copy instructs ffmpeg to copy the streams without re-encoding them. The -metadata:s:v:0 rotate=180 part targets the first video stream (s:v:0) and sets the rotation angle to 180 degrees. Adjust the angle based on your specific issue: use 90, 180, 270, or 0. Note that some older versions of ffmpeg may require you to use -metadata rotate=180 without the stream specifier if the tool fails to locate the specific stream index.

This approach is ideal when you know the metadata is broken but the video content itself is upright. However, if the video still appears sideways after this operation, the metadata was not being read by your player, or the pixel data itself is rotated. Proceed to Method 2 for a permanent fix.

Method 2: Physically Rotating Video Frames

When metadata updates fail, you must transform the actual pixel data. This involves re-encoding the video, which takes more time and may slightly reduce quality depending on the codec settings. You use the transpose filter within the -vf (video filter) option.

ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4

The transpose filter accepts integer values that define the rotation direction:

  • 0: Rotate 90 degrees counter-clockwise and flip vertically (default).
  • 1: Rotate 90 degrees clockwise.
  • 2: Rotate 90 degrees counter-clockwise.
  • 3: Rotate 90 degrees clockwise and flip vertically.

To flip a video completely upside down, you typically need two transposes. For example, rotating 180 degrees can be achieved by applying transpose=1 twice or using a combination of transpose and flip filters. A common pattern for a full 180-degree inversion is:

ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" -c:a copy output.mp4

Here, -c:a copy preserves the audio stream without re-encoding it, saving significant processing time. Only the video stream undergoes transformation. If you are dealing with high-resolution footage, consider adding -crf 23 (for H.264/H.265) to maintain a good balance between file size and quality during this re-encoding process.

Verifying the Fix

After running your chosen command, verify the output by playing it in multiple players. Web browsers, mobile devices, and desktop media players handle orientation differently. If one player shows the corrected video while another does not, check if the second player is ignoring metadata or if the filter application was incomplete.

For advanced users, inspecting the file properties with ffprobe can confirm the changes. Run the following command to view the stream details:

ffprobe -v error -select_streams v:0 -show_entries stream=width,height,codec_name -of default=noprint_wrappers=1:nokey=1 input.mp4

This helps ensure that the resolution dimensions have swapped correctly if a 90-degree rotation was applied. If you encounter issues with timestamp synchronization after heavy filtering, consider exploring related techniques such as those discussed in Fixing the 'ffmpeg -itsoffset is not working' Issue to manage timing offsets accurately.

Frequently Asked Questions

Why does my video look sideways on Instagram but normal on VLC?

Social media platforms often strip or ignore embedded rotation metadata tags during upload to standardize playback. VLC reads these tags natively, displaying the video correctly oriented. To fix this for social media, use the physical rotation method (Method 2) to bake the orientation into the pixel data permanently before uploading.

Can I rotate a video without losing quality?

Updating metadata tags is lossless and preserves original quality. However, physically rotating frames using filters requires re-encoding, which introduces generation loss. Using a high Constant Rate Factor (CRF) value, such as 18-23 for H.264, minimizes visible quality degradation during this process.

What if the audio is out of sync after rotating?

Physical rotation filters generally do not affect audio timing. If sync issues arise, they are likely due to other factors like variable frame rates or complex filter chains. Ensure you are copying the audio stream (-c:a copy) rather than re-encoding it unless necessary, as re-encoding can sometimes introduce minor delays if not handled carefully.

How do I rotate a video 180 degrees specifically?

Apply the transpose filter twice. The command -vf "transpose=1,transpose=1" rotates the video 90 degrees clockwise twice, resulting in a 180-degree flip. Alternatively, you can combine transpose with horizontal or vertical flip filters depending on the desired final orientation relative to the original capture.

Does ffmpeg support batch processing for multiple files?

Yes, you can use shell loops or ffmpeg's built-in glob patterns to process multiple files at once. For example, in Linux or macOS, you can iterate through all MP4 files in a directory and apply the rotation filter to each, creating a new output file for every input.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More