[SOLVED] Displaying video that was shot upside down?

Started by yetanotherlogin, April 12, 2021, 08:26:09 AM

Previous topic - Next topic

yetanotherlogin

Hello,

When using a mini tripod, 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.

eumagga0x2a

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.

butterw

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.






yetanotherlogin

Thanks for the infos.

So I'll just run the videos through ffmpeg before editing in AviDemux.

eumagga0x2a

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.

yetanotherlogin

I saw it mentioned elsewhere.

What would you suggest?

eumagga0x2a

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" 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.

yetanotherlogin


xyzzy

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.