MP4 Video wrong orientation if made in portrait

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

MP4 Video wrong orientation if made in portrait

Post by *Horst.Epp »

I have many mp4 videos made in portrait mode.
Most of it are displayed by TC with the wrong rotated orientation.
This is regradless of using the LAV filters installed in TC
or the the System default filters which are K-Lite_Codec_Pack_1620_Basic.

Windows media player, VLC and Explorer preview in TC are all playing in correct orientation.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *petermad »

I can confirm that for videos recorded with my 3 different Smart Phones in portrait mode.

I have different results in Windows 7 and Windows 10 for the same programs:

Windows 7:
Windows Media Player, MMedia TC plugin, Explorer Preview, IrfanView and XnView shows Landscape.
XnView MP shows upside-down Portrait
MPC Player, DivX Player and Quicktime Player shows Portrait.

Windows 10:
Windows Media Player, MPC Player, Quicktime Player, MMedia TC plugin and IrfanView shows Portrait
Explorer Preview only shows a Still picture
XnView shows Landscape
Windows Photos App and Windows Movies & TV App shows Portrait
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *ghisler(Author) »

I do not have any videos which play with wrong orientation. Could you send me a link to such a video by e-mail? Or a small video to cghisler at gmail dot com?
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: MP4 Video wrong orientation if made in portrait

Post by *Horst.Epp »

ghisler(Author) wrote: 2021-05-23, 08:38 UTC I do not have any videos which play with wrong orientation. Could you send me a link to such a video by e-mail? Or a small video to cghisler at gmail dot com?
Mail send
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *petermad »

2ghisler(Author)

You can also try this: https://madsenworld.dk/tcmd/portraitmovie.mp4
In contrast to this: https://madsenworld.dk/tcmd/landscapemovie.mp4
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *ghisler(Author) »

Thanks for the videos.
portraitmovie.mp4 is played in portrait mode here by VLC (correct), but in landscape mode by Windows Media Player Classic with the LAV Video codecs (incorrect).
graphstudionext.exe also plays it in landscape mode (incorrect).

Maybe I need to add a filter to rotate the image? Any ideas?
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: MP4 Video wrong orientation if made in portrait

Post by *Usher »

2ghisler(Author)
What Media Player Classic do you mean?
For me both MPC-HC and MPC-BC play in portrait mode while VLC (3.0.14) and Windows Media Player 11 play in landscape mode. I can't find needed option in VLC.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: MP4 Video wrong orientation if made in portrait

Post by *Horst.Epp »

Usher wrote: 2021-05-23, 19:55 UTC 2ghisler(Author)
What Media Player Classic do you mean?
For me both MPC-HC and MPC-BC play in portrait mode while VLC (3.0.14) and Windows Media Player 11 play in landscape mode. I can't find needed option in VLC.
VLC without any special option plays correct in portrait.
Also Windows Media and Explorer preview play in portrait with K-Lite Codecs.
Only problem is TC which plays wrong regardless of Codecs (LAV or K-Lite)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *ghisler(Author) »

The pixels in the video are actually stored in landscape mode, there is just an indication in the header that the video needs to be rotated. So apparently some filters do this decoding, others don't.

Can you see in graphstudionext or graphedit whether they add an extra filter? Or check the filter chain in the right click menu of Media Player Classic for any rotation filters?

According to Stackoverflow replies, DirectShow does NOT support the rotation of videos by itself, see e.g.:
https://stackoverflow.com/questions/30194580/direct-show-camera-rotation-90-degree
So it either needs to be supported by the video decoder filter, or another filter needs to be added which does the rotation. I found a project which claims to do it, but it crashes when adding the filter. There is also a commercial project I haven't tried yet.
What Media Player Classic do you mean?
I'm using "Media Player Classic - Home Cinema" from http://www.cccp-project.net/ which is unfortunately no longer maintained.

Edit: I found someething interesting: LAV filters do not rotate the video, but they pass the information to the video renderer which would then have to rotate it:
https://forum.doom9.org/showthread.php?p=1758791

Apparently only the MadVR renderer supports rotation, but I cannot use it because MadVR does not support windowless output. I'm using the Windows "Enhanved Video Renderer", which supports windowless output (sent to my own window), but does not support video rotation.

I have to use windowless output because my player is entirely working in a background thread, so it cannot freeze Lister. Windowed output as used by MadVR outputs to its own window control. If I set that window as a child of Lister, then a hanging player would also hang Lister and Total Commander.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *petermad »

2ghisler(Author)
Can you see in graphstudionext or graphedit whether they add an extra filter? Or check the filter chain in the right click menu of Media Player Classic for any rotation filters?
Here is what I se in graphstudionext64: https://madsenworld.dk/tcmd/graphstudionext64.png - graphstudionext64 does NOT rotate the video correctly (Windows 7) - All 3 LAV filters are registered system wide (otherwise I get an error from graphstudionext64.exe)

Here is what I se in graphstudionext: https://madsenworld.dk/tcmd/graphstudionext.png - and graphstudionext does NOT rotate the video - with the 32bit version I have not registered the LAV filters.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *ghisler(Author) »

That's not what I meant - I meant using File - Connect to remote graph when a video player with correctly rotated video is playing. This will NOT work with VLC because VLC isn't using DirectShow.

Btw, here it works correctly with MPC-HC when I change the output filter to the MadVR renderer - the one I can't use.
I will probably have to write my own rotation filter...
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: MP4 Video wrong orientation if made in portrait

Post by *Usher »

ghisler(Author) wrote: 2021-05-24, 08:27 UTC
What Media Player Classic do you mean?
I'm using "Media Player Classic - Home Cinema" from http://www.cccp-project.net/ which is unfortunately no longer maintained.
Your MPC-HC version is very outdated. MPC-HC was developed on mpc-hc.org and is still maintained on Github by one of the developers.
I've been already posted the proper link https://github.com/clsid2/mpc-hc
See also older topic: viewtopic.php?f=15&t=74180&p=398768#p398768
ghisler(Author) wrote: 2021-05-24, 08:27 UTC Edit: I found someething interesting: LAV filters do not rotate the video, but they pass the information to the video renderer which would then have to rotate it:
https://forum.doom9.org/showthread.php?p=1758791
Apparently only the MadVR renderer supports rotation, but I cannot use it because MadVR does not support windowless output.
Apparently I have to change video renderer in VLC. Thanks for the info.

EDIT. Changed video output in VLC from DirectX (DirectDraw) to Automatic and now it works OK.
Aparrently @Horst.Epp doesn't know this very special VLC option ;-P
Last edited by Usher on 2021-05-24, 18:31 UTC, edited 1 time in total.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *petermad »

2ghisler(Author)
portraitmovie.mp4 is played in portrait mode here by VLC (correct), but in landscape mode by Windows Media Player Classic with the LAV Video codecs (incorrect).
HMM, it playes in portrait in my Windows Media Player Classic v. 1.7.13
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: MP4 Video wrong orientation if made in portrait

Post by *ghisler(Author) »

As I wrote, it depends on the output filter used. MadVR and newer internal MPC-HC output filters seem to support it, the one I used (Windows Enhanced Video Renderer) doesn't. Writing my own video renderer filter is out of the question, it's very complex and requires handling of Direct3d and other complex things. Writing my own rotation filter is a possibility, I made some tests and it seems to be doable, but it's also time consuming.
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: MP4 Video wrong orientation if made in portrait

Post by *Horst.Epp »

ghisler(Author) wrote: 2021-05-25, 15:55 UTC As I wrote, it depends on the output filter used. MadVR and newer internal MPC-HC output filters seem to support it, the one I used (Windows Enhanced Video Renderer) doesn't. Writing my own video renderer filter is out of the question, it's very complex and requires handling of Direct3d and other complex things. Writing my own rotation filter is a possibility, I made some tests and it seems to be doable, but it's also time consuming.
Personaly I don't care much for this bug.
I can just switch to Explorer preview for such videos.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Post Reply