Opened 5 years ago

Closed 5 years ago

#13400 closed Bug Report - General (fixed)

Video playback wrong aspect ratio

Reported by: Klaas de Waal Owned by: Klaas de Waal
Priority: minor Milestone: 31.0
Component: MythTV - Video Playback Version: Master Head
Severity: medium Keywords: video playback gui qt
Cc: Stuart Auchterlonie, David Hampton Ticket locked: no

Description (last modified by Peter Bennett)

Aspect ratio is calculated incorrectly on systems with two monitors.

Prior description - Video playback with mythfrontend now has the wrong aspect ratio. Also the on-screen "Paused" display has disappeared.

A version of mythtv master compiled two days ago is correct; a version compiled today is wrong.

Attached are two screenshots of the same recording with the different frontends, both paused at approximately the same moment.

Version of the old/correct mythfrontend:

[klaas@modu mma-dvbt]$ mythfrontend --version
Please attach all output as a file in bug reports.
MythTV Version : v31-Pre-47-g4543b46083-dirty
MythTV Branch : master
Network Protocol : 91
Library API : 31.20190109-1
QT Version : 5.11.3
Options compiled in:
 linux profile use_hidesyms using_alsa using_oss using_pulse using_pulseoutput using_backend using_bindings_perl using_bindings_python using_bindings_php using_crystalhd using_dvb using_firewire using_frontend using_hdhomerun using_vbox using_ceton using_hdpvr using_ivtv using_joystick_menu using_libcec using_libcrypto using_libdns_sd using_libfftw3 using_libxml2 using_lirc using_mheg using_opengl using_opengl_video using_opengl_themepainter using_qtwebkit using_qtscript using_qtdbus using_taglib using_v4l2 using_x11 using_xnvctrl using_xnvctrl_external using_libbluray_external using_xrandr using_xv using_profiletype using_systemd_notify using_systemd_journal using_bindings_perl using_bindings_python using_bindings_php using_freetype2 using_mythtranscode using_opengl using_vaapi using_vaapi2 using_nvdec using_vdpau using_ffmpeg_threads using_mheg using_libass using_libxml2
[klaas@modu mma-dvbt]$ 

Version of new/wrong mythfrontend:

[klaas@modu mma]$ mythfrontend --version
Please attach all output as a file in bug reports.
MythTV Version : v31-Pre-56-gfa86a6a293
MythTV Branch : master
Network Protocol : 91
Library API : 31.20190109-1
QT Version : 5.11.3
Options compiled in:
 linux profile use_hidesyms using_alsa using_oss using_pulse using_pulseoutput using_backend using_bindings_perl using_bindings_python using_bindings_php using_crystalhd using_dvb using_firewire using_frontend using_hdhomerun using_vbox using_ceton using_hdpvr using_ivtv using_joystick_menu using_libcec using_libcrypto using_libdns_sd using_libfftw3 using_libxml2 using_lirc using_mheg using_opengl using_opengl_video using_opengl_themepainter using_qtwebkit using_qtscript using_qtdbus using_taglib using_v4l2 using_x11 using_xnvctrl using_xnvctrl_external using_libbluray_external using_xrandr using_xv using_profiletype using_systemd_notify using_systemd_journal using_bindings_perl using_bindings_python using_bindings_php using_freetype2 using_mythtranscode using_opengl using_vaapi using_vaapi2 using_nvdec using_vdpau using_ffmpeg_threads using_mheg using_libass using_libxml2
[klaas@modu mma]$ 

The mythfrontend log files are also attached.

Linux system is Fedora 29, no video hardware.

This problem could have been introduced with the GUI-related commits of Feb 4, 2019 by linuxdude42.

Attachments (9)

Selection_003.png (925.5 KB) - added by Klaas de Waal 5 years ago.
Screenshot with correct aspect ratio, with the "old" version of mythfrontend compiled two days ago.
Selection_004.png (621.4 KB) - added by Klaas de Waal 5 years ago.
Screenshot with wrong aspect ratio and "Paused" OSD missing , with the version of mythfrontend compiled today.
mf-20190205-1435-bad.log (28.5 KB) - added by Klaas de Waal 5 years ago.
Log file of mythfrontend with wrong aspect ratio and "Paused" OSD missing , the version of mythfrontend compiled today.
mf-20190205-1436-ok.log (26.3 KB) - added by Klaas de Waal 5 years ago.
Logfile of mythfrontend with correct aspect ratio, from the "old" version of mythfrontend compiled two days ago.
Selection_005_Normal.png (577.0 KB) - added by Klaas de Waal 5 years ago.
Video playback paused with the "Normal" profile.
Selection_006_VAAPI2_Normal.png (638.0 KB) - added by Klaas de Waal 5 years ago.
Paused video playback with "VAAPI2 Normal" profile.
mf-20190206-1041.log (27.4 KB) - added by Klaas de Waal 5 years ago.
Logfile of mythfrontend with perfect aspect ratio, from the latest version of mythfrontend but with only one screen connected to the system.
20190206-video-aspect.patch (681 bytes) - added by Klaas de Waal 5 years ago.
FIx for video aspect ratio on multi-screen system that are seen as a single big screen.
20190306-video-aspect.patch (638 bytes) - added by Klaas de Waal 5 years ago.
Functionally the same as the 20190206 patch but looks better.

Change History (30)

Changed 5 years ago by Klaas de Waal

Attachment: Selection_003.png added

Screenshot with correct aspect ratio, with the "old" version of mythfrontend compiled two days ago.

Changed 5 years ago by Klaas de Waal

Attachment: Selection_004.png added

Screenshot with wrong aspect ratio and "Paused" OSD missing , with the version of mythfrontend compiled today.

Changed 5 years ago by Klaas de Waal

Attachment: mf-20190205-1435-bad.log added

Log file of mythfrontend with wrong aspect ratio and "Paused" OSD missing , the version of mythfrontend compiled today.

Changed 5 years ago by Klaas de Waal

Attachment: mf-20190205-1436-ok.log added

Logfile of mythfrontend with correct aspect ratio, from the "old" version of mythfrontend compiled two days ago.

comment:1 Changed 5 years ago by Peter Bennett

v31-Pre-47-g4543b46083a is working ok.

comment:2 Changed 5 years ago by Peter Bennett

Status: newinfoneeded_new

v31-Pre-57-g4f58fd152f seems to be working fine - I have tested with vaapi2 and opengl playback profiles.

Aspect ratio is fine. OSD shows fine.

Please let me know the playback profile you are using, and the display hardware.

I notice with Normal playback profile, the OSD is not working. I think that was reported a few days ago.

comment:3 Changed 5 years ago by Peter Bennett

I have fixed the issue with OSD on Slim, Normal, etc.

comment:4 Changed 5 years ago by Peter Bennett

Milestone: needs_triage31.0
Priority: blockerminor

comment:5 Changed 5 years ago by Klaas de Waal

Hardware is Intel i7-7700 with built-in graphics.
Video playback profile is Normal.
With the "VAAPI2 Normal" the OSD is OK but the aspect ratio is still wrong.

comment:6 Changed 5 years ago by Klaas de Waal

Hardware is Intel i7-7700 with built-in graphics.
Video playback profile is Normal.
Have now tested with "VAAPI2 Normal" and then the OSD is OK but the video aspect ratio is still wrong.

comment:7 Changed 5 years ago by Klaas de Waal

Recompiled the latest just now, MythTV Version : v31-Pre-58-g144ac28c00
With video playback profile "Normal" the OSD is fixed but aspect ratio of video and OSD is still wrong.
With video playback profile "VAAPI2 Normal" the aspect ratio of the video is still wrong but the aspect ratio of the OSD is correct.
Screenshots will be attached.

Changed 5 years ago by Klaas de Waal

Attachment: Selection_005_Normal.png added

Video playback paused with the "Normal" profile.

Changed 5 years ago by Klaas de Waal

Paused video playback with "VAAPI2 Normal" profile.

comment:8 Changed 5 years ago by Peter Bennett

Nobody here sees this problem.

Please check mythfrontend setup -> video -> playback -> general playback and make sure you have no setting in scaling or video aspect override.

comment:9 Changed 5 years ago by Klaas de Waal

Progress!!
My system has two monitors, the first is 1920x1200 and the second is 1920x1080.
When I disconnect the second monitor and reboot the system then the video playback aspect ratio is correct!!

Looking now again at the differences in the log files, the first significant differences are the display dimensions in line 171.
The log file of a few days ago, mf-20190205-1436-ok.log, shows this (lines 170-172):

2019-02-05 14:36:48.992544 I  VideoOutput: Pixel dimensions: Screen 1920x1200, window 1280x720
2019-02-05 14:36:48.992599 I  VideoOutput: Xinerama display dimensions: 564x317 mm  Aspect: 1.77918
2019-02-05 14:36:48.992610 I  VideoOutput: Estimated window dimensions: 376x190 mm  Aspect: 1.97895

The display rectangle is then computed as 1150x720 (lines 202-203):

2019-02-05 14:36:49.044388 I  Display Rect  left: 65, top: 0, width: 1150, height: 720, aspect: 1.97895
2019-02-05 14:36:49.044390 I  Video Rect    left: 0, top: 0, width: 1920, height: 1080, aspect: 1.77778

The log file mf-20190205-1435-bad.log shows a much larger width and it is called "Actual display dimensions" instead of "Xinerama display dimensions" (lines 170-172):

2019-02-05 14:35:29.816328 I  VideoOutput: Pixel dimensions: Screen 1920x1200, window 1280x720
2019-02-05 14:35:29.816332 I  VideoOutput: Actual display dimensions: 1016x317 mm  Aspect: 3.20505
2019-02-05 14:35:29.816334 I  VideoOutput: Estimated window dimensions: 677x190 mm  Aspect: 3.56316

This looks like the width is the total width of both screens.
The display rectangle is then computed as 639x720 (lines 202-203):

2019-02-05 14:35:29.851136 I  Display Rect  left: 320, top: 0, width: 639, height: 720, aspect: 3.56316
2019-02-05 14:35:29.851139 I  Video Rect    left: 0, top: 0, width: 1920, height: 1080, aspect: 1.77778

A new log file, mf-20190206-1041.log (to be attached), from the latest master but with only the first screen connected, shows this (lines 171-173):

2019-02-06 10:41:26.046554 I  VideoOutput: Pixel dimensions: Screen 1920x1200, window 1280x720
2019-02-06 10:41:26.046558 I  VideoOutput: Actual display dimensions: 508x317 mm  Aspect: 1.60252
2019-02-06 10:41:26.046560 I  VideoOutput: Estimated window dimensions: 338x190 mm  Aspect: 1.77895

The display rectangle is then computed as 1280x720 (lines 203-204):

2019-02-06 10:41:26.081123 I  Display Rect  left: 0, top: 0, width: 1280, height: 720, aspect: 1.77778
2019-02-06 10:41:26.081126 I  Video Rect    left: 0, top: 0, width: 1920, height: 1080, aspect: 1.77778

The 1280x720 is exactly the size of the window so that is very much OK. The video now fills the window exactly which is better than with the version of a few days ago which computes the window as 1150x720.

So the problem is that the video rectangle computation needs to be fixed for the case in which people have more than one screen and run MythTV frontend in a window.

Changed 5 years ago by Klaas de Waal

Attachment: mf-20190206-1041.log added

Logfile of mythfrontend with perfect aspect ratio, from the latest version of mythfrontend but with only one screen connected to the system.

comment:10 Changed 5 years ago by jpilk

I see this too, Master 144ac28c008 Fedora 28 VDPAU. Screens are

monitor, default, windowed 1024x576+64+64 in 1680x1050

and TV, unwindowed, run with 'mythfrontend -nw --geometry 1920x1080+1680+0'

OSD is normal size but playback about half-width, centred. Menu > Video > Aspect ratio has no effect.

FWIW Firestick 4K frontend on TV is fine.

Version 0, edited 5 years ago by jpilk (next)

comment:11 Changed 5 years ago by Peter Bennett

Resolution: Invalid
Status: infoneeded_newclosed

Closing this as it is not a bug but a restriction when using multiple monitors in xinerama mode. What I do for this situation, is as follows

Set up a unique user id for Mythfrontend. Log on with that user and use display setup to disable one monitor. Every time you logon with that user you get one screen, when logging on with a different user id you can use both screens.

comment:12 Changed 5 years ago by jpilk

Perhaps I misunderstand; but I can (and do) stop and restart either frontend display 'instantaneously' from the command line. Logging in as a different user takes minutes. 'Restriction' seems an understatement.

comment:13 Changed 5 years ago by David Hampton

I only saw this once in my testing for change b2c82a3665, and then the problem went away. I could never recreate it after that. I will try and recreate it again.

comment:14 Changed 5 years ago by jpilk

Thanks. I should probably have said that my setup is using XScreen0 only, and nVidia screen settings reports its dimensions as 3600x1080, ie (1680+1920)x1080, clearly based on the combined pixel-widths of the two screens.

comment:15 Changed 5 years ago by Klaas de Waal

Problem is that the video scaling uses the pixels of only the first screen, 1920x1200, and the dimensions in mm of both screens together. Fixed this by using the pixel area of both screens together, 3840x1200. Patch is attached.

Caveat: I have not gone into the very depths of the video stuff so this might not be the best solution possible but at least for me this is better than using only a single screen.

Changed 5 years ago by Klaas de Waal

Attachment: 20190206-video-aspect.patch added

FIx for video aspect ratio on multi-screen system that are seen as a single big screen.

comment:16 Changed 5 years ago by Peter Bennett

Description: modified (diff)
Resolution: Invalid
Status: closednew

Re-opened for consideration of the patch

comment:17 in reply to:  11 Changed 5 years ago by Stuart Auchterlonie

Replying to Peter Bennett:

Set up a unique user id for Mythfrontend. Log on with that user and use display setup to disable one monitor. Every time you logon with that user you get one screen, when logging on with a different user id you can use both screens.

Realistically this isn't the best approach. My dev frontend systems have 2 monitors connected, which allows a nice testing setup (ie. debuggers, code etc on one screen, and the frontend on the other screen), or watching stuff you need to catch up on whilst doing some other stuff at the same time.

comment:18 Changed 5 years ago by jpilk

I have applied the patch from Comment 15 in a build for Fedora 28 of today's master, c6a7cf187, and tested with normal playback and that of recorded BBC SD and HD testcards. The pictures now exactly fill the window-on-monitor or TV-screen, as they did before the commit that prompted this ticket. I haven't yet tried it on a single-screen system...

My mode of operation with two screens is described is this post:

http://lists.mythtv.org/pipermail/mythtv-users/2019-March/399749.html

comment:19 Changed 5 years ago by jpilk

No problem seen with my normal windowed playback on a single screen with old intel graphics

00:02.0 VGA compatible controller: Intel Corporation 82Q33 Express Integrated Graphics Controller (rev 02)

xorg-x11-drv-intel-2.99.917-28.20180530.el7.x86_64

and MythTV built from the same sources as in Comment 18

comment:20 Changed 5 years ago by Peter Bennett

Owner: changed from Peter Bennett to Klaas de Waal
Status: newassigned

Changed 5 years ago by Klaas de Waal

Attachment: 20190306-video-aspect.patch added

Functionally the same as the 20190206 patch but looks better.

comment:21 Changed 5 years ago by Klaas de Waal <kdewaal@…>

Resolution: fixed
Status: assignedclosed

In 5de99ad3d7/mythtv:

Video aspect ratio wrong on systems with multiple monitors

On a system with two monitors, positioned horizontally next to each other,
the vertical size of the video in a window is correct but the horizontal size
is about half what it should be.
The same is true for full-screen video, without an enclosing window.

This problem is most likely introduced in commit b2c82a3, dated Feb 1,
"Convert from QDesktopWindow to QScreen".

Before this commit a system with multiple monitors was treaded as "Xinerama".
After this commit a system with mulitple monitors is seen as one big screen
with an area which is the bounding box of the screens of all monitors.
The name display as used in the code now refers to the big "bounding box" screen.

The video aspect ratio computations use the size of the display in mm.
The bug was here that the display size in mm was used in conjunction
with the size in pixels of the first screen.
In order to scale correct the size in pixels of the display has to be used.

Note: the change from QDesktopWidget to QScreen is a Good Thing because
the QDesktopWidget is declared obsolete.
Note: with this fix included the video scaling in a multiple monitor
system is now exact which is better than before, in the "Xinerama" mode.

Fixes #13400

Note: See TracTickets for help on using tickets.