Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: yetanotherlogin on April 12, 2021, 08:26:09 AM

Title: [SOLVED] Displaying video that was shot upside down?
Post by: yetanotherlogin on April 12, 2021, 08:26:09 AM
Hello,

When using a mini tripod (https://www.aliexpress.com/item/mini-tripod-phone-holder/4000937907156.html), I find it easier to hold and use a smarphone upside down so I can turn the screen on/off with my thumb.

This info is saved in the file:
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1280x720, 13836 kb/s, SAR 1:1 DAR 16:9, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate          : 180
creation_time  : 2021-04-11T12:02:03.000000Z
handler_name    : VideoHandle
vendor_id      : [0][0][0][0]
Side data:
displaymatrix: rotation of -180.00 degrees

VLC knows how to display the video accordingly, but by default, AviDemux doesn't.

Can it be told to display the video correctly, or is the following pre-step the only way?

ffmpeg -i original.mp4 -c:a copy original.rotated.mp4
Thank you.
Title: Re: Displaying video that was shot upside down?
Post by: eumagga0x2a on April 12, 2021, 08:50:54 AM
You cannot make Avidemux apply transformations requested by metadata to video on display, which is by design, but you need to set the appropriate rotation metadata in the configuration of the MP4 muxer in Avidemux.
Title: Re: Displaying video that was shot upside down?
Post by: butterw on April 12, 2021, 10:29:28 AM
Cutting video with rotation metadata is going to be a pain in Avidemux: rotation metadata isn't applied.
- If you re-encode you can use the rotate filter.
- For lossless cutting you have to re-apply the rotation value in the container options when saving.





Title: Re: Displaying video that was shot upside down?
Post by: yetanotherlogin on April 12, 2021, 11:12:24 AM
Thanks for the infos.

So I'll just run the videos through ffmpeg before editing in AviDemux.
Title: Re: [SOLVED] Displaying video that was shot upside down?
Post by: eumagga0x2a on April 12, 2021, 11:23:13 AM
Quote from: yetanotherlogin on April 12, 2021, 11:12:24 AMSo I'll just run the videos through ffmpeg before editing in AviDemux.

A terrible idea, especially when using verbatim the ffmpeg command line from above.
Title: Re: [SOLVED] Displaying video that was shot upside down?
Post by: yetanotherlogin on April 12, 2021, 08:02:35 PM
I saw it mentioned elsewhere.

What would you suggest?
Title: Re: [SOLVED] Displaying video that was shot upside down?
Post by: eumagga0x2a on April 12, 2021, 09:22:18 PM
If some minimal quality loss is acceptable while cutting in copy mode "upside down" is not, I would suggest re-encoding the full video with "rotate" filter applied using the "Mezzanine (https://github.com/mean00/avidemux2/blob/master/avidemux_plugins/ADM_videoEncoder/x264/preset/Mezzanine.json)" x264 preset. If storage space is not an issue, I would recommend using the lossless Ut Video encoder in Avidemux instead of x264 for all intermediate steps.

Regarding your command line, if your ffmpeg is not very old, it will by default use libx264 to re-encode the video, with considerable loss of quality. Older ffmpeg versions were using DivX and the quality loss was horrendous. IMHO, the goal should be to keep quality as close to original as possible.
Title: Re: [SOLVED] Displaying video that was shot upside down?
Post by: yetanotherlogin on April 13, 2021, 01:59:43 PM
I'll give it a shot. Thank you.
Title: Re: [SOLVED] Displaying video that was shot upside down?
Post by: xyzzy on April 20, 2021, 12:53:56 PM
Could you make a low(er) quality re-encode with orientation corrected to right side up, using ffmpeg.  Edit that with avidemux.  Add avidemux rotate filter.  Instead of encoding in avidemux, save a project file and edit the project file manually to use the original upside down file instead of the re-encoded right side up file.  Now run the project and it will edit the original file and rotate it at the same time.