[FFmpeg-user] Rotate metadata flag not applied on mp4 ?

Ferdi Scholten ferdi at sttc-nlp.nl
Sat Jul 6 22:22:21 EEST 2024


Hi,
> I have a few videos that have been shot upside down but lack the rotate
> flag so they play upside down in e.g. VLC.
> Here is an example :
> https://www.swisstransfer.com/d/48602faa-73aa-4c6d-b3bf-d2db6b2ffe9c
>
> I'd like to add the rotation information without reencoding. Many pages
> indicate it can be done with "-metadata:s:v rotate=180".
That is deprecated and does not work (as you have already found out.

Use these instead (excerpt of the ffmpeg documenteation)

-display_rotation[:stream_specifier] rotation (/input,per-stream/)

    Set video rotation metadata.

    rotation is a decimal number specifying the amount in degree by
    which the video should be rotated counter-clockwise before being
    displayed.

    This option overrides the rotation/display transform metadata stored
    in the file, if any. When the video is being transcoded (rather than
    copied) and |-autorotate| is enabled, the video will be rotated at
    the filtering stage. Otherwise, the metadata will be written into
    the output file if the muxer supports it.

    If the |-display_hflip| and/or |-display_vflip| options are given,
    they are applied after the rotation specified by this option.

-display_hflip[:stream_specifier] (/input,per-stream/)

    Set whether on display the image should be horizontally flipped.

    See the |-display_rotation| option for more details.

-display_vflip[:stream_specifier] (/input,per-stream/)

    Set whether on display the image should be vertically flipped.

    See the |-display_rotation| option for more details.


These need to be set BEFORE the inputvideo (before -i)! For example 90 
degree counter-clockwise rotation:

|ffmpeg -display_rotation:v:0 90.0 -i input.mp4 -c copy output.mp4|


More information about the ffmpeg-user mailing list