moonlight-stream / moonlight-qt

GameStream client for PCs (Windows, Mac, Linux, and Steam Link)
GNU General Public License v3.0
10.16k stars 594 forks source link

Automatically switch resolution when starting a stream (ideal for Ultrawide users) #784

Open fayewave opened 2 years ago

fayewave commented 2 years ago

Currently, users with Ultrawide displays have to manually switch to 16:9 before streaming, otherwise streams will be squished.

It would be great if Moonlight could automatically switch to a 16:9 resolution for users with Ultrawide displays, and then once a stream is stopped, Moonlight switches everything back to normal.

michaeldperlo commented 2 years ago

Yes! I have a 21:9 display and no matter how I fiddle with both the host and client resolution settings on my Android phone, the host image is always stretched vertically to fill the client screen. On my iPhone I can set a custom resolution of 3440x1440 and it will display my host screen accurately (with letterboxing on top and bottom). With Steam Link when I connect on either Android or iOS it automatically adjusts the host resolution to 16:9, which then displays perfectly on my clients. Am I doing something wrong?

cgutman commented 2 years ago

Geforce Experience on your host PC will change the desktop resolution to a 16:9 mode when you directly stream a game. It won’t change the desktop resolution when you stream the full desktop using the mstsc.exe trick, even if you start a game within the stream.

Moonlight doesn’t have specific control over desktop resolution on the host. We ask GFE to pick a particular resolution (which is equal to the resolution you select in the Moonlight settings), however GFE ignores our requested desktop resolution in a number of known situations such as:

Note that the above refers only to the desktop resolution. The game itself may adjust your desktop resolution regardless of what GFE does. Desktop resolution is independent from the resolution of the video stream, which always matches what it selected in Moonlight. In the event that desktop resolution doesn’t match the video stream resolution, GeForce Experience will use a stretch-to-fill scaling technique to fit the desktop resolution into the video resolution.

michaeldperlo commented 2 years ago

Hey Cameron-

Thanks so much for replying so quickly. Here’s a more thorough summary of what I’m experiencing. I should note that this is affecting games being streamed — I don’t use the mstsc Remote Desktop feature.

I have a 34” 21:9 monitor running at 3440x1440 resolution. When I open Steam Link or Parsec from my phones (I have both an Android and iPhone), the resolution on my host monitor automatically switches to 16:9. The games are then streamed to my phones at that resolution.

When I open the Moonlight app on my phone the resolution of my host monitor remains at 16:9 regardless of what I set the resolution in Moonlight at (I’ve tried 1080p, 1440p and a custom 3440x1440p). This creates different effects on each phone.

On my Android the stream remains in 21:9 but is stretched vertically to fill the phone’s screen. Changing the resolution in the Moonlight Android app doesn’t change anything. Nor does selecting “stretch to fullscreen” or “optimize games for streaming”. In order to get the game to stream properly in 16:9 I need to go into each game’s settings and change the resolution in there.

On my iPhone it works a little different. When I set the Moonlight client’s resolution to 1080p the stream appears in 16:9, but since the host is still feeding it a 21:9 stream, the image on my phone appears squished. When I set the Moonlight client’s resolution to a custom 3440x1440, the game stream remains in 21:9 and appears correctly on the phone (with letterboxing on the top and bottom).

So it seems to me that the issue is that Moonlight (or GFE) isn’t changing the stream resolution no matter what rez I select in the Moonlight host app. When I connect with other apps like Steam Link or Parsec, the host desktop / screen resolution automatically flips to 16:9 and then switches back to 21:9 when I disconnect. I’ve attached some screenshots to help illustrate the issue I’m facing. What are your thoughts?

Many thanks, Michael

Parsec_Host_Screen Parsec_Host_Screen

Moonlight_Android_16x9Client Moonlight_Android_16x9Client

Moonlight_iPhone_16x9Client Moonlight_iPhone_16x9Client

Moonlight_iPhone_21x9Client Moonlight_iPhone_21x9Client

Parsec_Client_16x9 Parsec_Client_16x9

Moonlight_Settings Moonlight_Settings

Moonlight_Host_Screen Moonlight_Host_Screen

cgutman commented 2 years ago

Hey Cameron-

Thanks so much for replying so quickly. Here’s a more thorough summary of what I’m experiencing. I should note that this is affecting games being streamed — I don’t use the mstsc Remote Desktop feature.

Did you need to manually add these games on the SHIELD tab in GeForce Experience to make them show up? I think GFE's resolution switching behavior may differ for officially supported games vs manually added games.

I have a 34” 21:9 monitor running at 3440x1440 resolution. When I open Steam Link or Parsec from my phones (I have both an Android and iPhone), the resolution on my host monitor automatically switches to 16:9. The games are then streamed to my phones at that resolution.

When I open the Moonlight app on my phone the resolution of my host monitor remains at 16:9 regardless of what I set the resolution in Moonlight at (I’ve tried 1080p, 1440p and a custom 3440x1440p). This creates different effects on each phone.

Remember, unlike Parsec and Steam Link, Moonlight is only client-side software. Since we don't write the host-side software (GeForce Experience), we cannot directly control what it chooses to do with your host PC's desktop resolution.

There are some companion apps that other developers have written such as https://github.com/cgarst/gamestream_launchpad that can address some of these limitations though.

On my Android the stream remains in 21:9 but is stretched vertically to fill the phone’s screen. Changing the resolution in the Moonlight Android app doesn’t change anything. Nor does selecting “stretch to fullscreen” or “optimize games for streaming”. In order to get the game to stream properly in 16:9 I need to go into each game’s settings and change the resolution in there.

What Android device are you testing with? Does it have a 16:9 display? I'd expect it to be letter/pillar-boxed if you chose a 16:9 resolution on a non-16:9 display, regardless of the host PC's desktop resolution.

On my iPhone it works a little different. When I set the Moonlight client’s resolution to 1080p the stream appears in 16:9, but since the host is still feeding it a 21:9 stream, the image on my phone appears squished. When I set the Moonlight client’s resolution to a custom 3440x1440, the game stream remains in 21:9 and appears correctly on the phone (with letterboxing on the top and bottom).

This is the behavior I would expect all Moonlight clients to have. Since GFE uses a stretch-to-fill technique for converting desktop resolution to the video stream resolution, the 21:9 desktop would be squished into a 16:9 aspect ratio video stream. Moonlight receives the squished 16:9 stream from the host and pillarboxes it for your iPhone's display.

So it seems to me that the issue is that Moonlight (or GFE) isn’t changing the stream resolution no matter what rez I select in the Moonlight host app. When I connect with other apps like Steam Link or Parsec, the host desktop / screen resolution automatically flips to 16:9 and then switches back to 21:9 when I disconnect. I’ve attached some screenshots to help illustrate the issue I’m facing. What are your thoughts?

Many thanks, Michael

Moonlight_Settings Moonlight_Settings

Just to clarify, you only need the Moonlight PC client for streaming from another PC. You don't need it installed on your host gaming PC. The settings in there don't have any effect for hosting.

hansschmucker commented 2 years ago

It's not ideal, but I've written a little utility which you can download over at https://github.com/hansschmucker/NVStreamer1080/releases/tag/v1.0.0.0 What it does is either switch to a second screen or set the current one to 1920x1080/60 whenever nvstreamer is active and return to the previous setup afterwards.

It automatically adds itself to the autostart and runs in background... I've been running this for a year or so and it works pretty well for me.

For my home setup I've added a 1080p HDMI dummy and use the utility to switch to that screen... which actually is necessary in my case since NVidia still has a bug where you can't gamestream while connected to a DisplayPort screen if that screen isn't turned on and well, mine usually is off.

michaeldperlo commented 2 years ago

Thanks for the link and info man! I’ll definitely check it out. Lately I’ve been using Playnite with GameStream Launchpad (which changes desktop resolutions) and it does the trick. It’s still a little bit of a drag to have to launch Playnite in Moonlight then select a game instead of just selecting one straight from Moonlight, but it’s all good. Quick question about your tool — is it possible to have it work with other resolutions — like 1440p and 4K?


From: hansschmucker @.> Sent: Tuesday, July 19, 2022 3:03:04 PM To: moonlight-stream/moonlight-qt @.> Cc: michaeldperlo @.>; Comment @.> Subject: Re: [moonlight-stream/moonlight-qt] Automatically switch resolution when starting a stream (ideal for Ultrawide users) (Issue #784)

It's not ideal, but I've written a little utility which you can download over at https://github.com/hansschmucker/NVStreamer1080/releases/tag/v1.0.0.0 What it does is either switch to a second screen or set the current one to 1920x1080/60 whenever nvstreamer is active and return to the previous setup afterwards.

It automatically adds itself to the autostart and runs in background... I've been running this for a year or so and it works pretty well for me.

For my home setup I've added a 1080p HDMI dummy and use the utility to switch to that screen... which actually is necessary in my case since NVidia still has a bug where you can't gamestream while connected to a DisplayPort screen if that screen isn't turned on and well, mine usually is off.

— Reply to this email directly, view it on GitHubhttps://github.com/moonlight-stream/moonlight-qt/issues/784#issuecomment-1189594974, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZGL7ZWXYPAYG5HCAPNENQLVU4QZRANCNFSM5USAUINA. You are receiving this because you commented.Message ID: @.***>

hansschmucker commented 2 years ago

Not yet.. like I said, it was really just written for my own needs and I only published it because if this thread, but adding other resolutions is pretty easy, so I'll probably add it tonight after work, just don't expect a fancy dialog ^^

hansschmucker commented 2 years ago

Added custom resolution: https://github.com/hansschmucker/NVStreamer1080/releases/tag/v1.0.1.0 Have fun :)

michaeldperlo commented 2 years ago

Awesome man! Thanks so much! I tried using v1.0 but when a game would connect it would issue a Windows+P command and bring up the projection settings. I would have to close that whole streaming and then enter the game in fullscreen. I’ll see if it’s fixed in this new version!


From: hansschmucker @.> Sent: Thursday, July 21, 2022 10:29:36 AM To: moonlight-stream/moonlight-qt @.> Cc: michaeldperlo @.>; Comment @.> Subject: Re: [moonlight-stream/moonlight-qt] Automatically switch resolution when starting a stream (ideal for Ultrawide users) (Issue #784)

Added custom resolution: https://github.com/hansschmucker/NVStreamer1080/releases/tag/v1.0.1.0 Have fun :)

— Reply to this email directly, view it on GitHubhttps://github.com/moonlight-stream/moonlight-qt/issues/784#issuecomment-1191753231, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZGL7ZWMAVIRWREVMETIFEDVVGCIBANCNFSM5USAUINA. You are receiving this because you commented.Message ID: @.***>

hansschmucker commented 2 years ago

That's its primary mode, but it shouldn't do it if the checkbox is in a disabled state. I'll check tonight :) . Like I said it's how I actually use it : every time Moonlight connects the tool makes Windows switch to a dummy HDMI dongle. Still, with the checkbox unchecked it should do what you want...

georaldcamposano commented 2 years ago

Moonlight used to adjust aspect ratio properly for me (or I guess it's nvidia gamestream doing that?), so whenever I 4k streamed to my Shield TV, I would get the appropriate top and bottom black bars from my 3440x1440 host PC. This was useful too when streaming to my iphone since the aspect ratio was fairly close and would use up a good amount of the display. I don't know what changed but any resolution now gets stretched to a 16:9 window, on both the android and ios clients. The recent custom resolution option does help though with the iphone.

About resolutions, one thing I just realized is having DSR enabled in the nvidia control panel seems to be a must in order to select 3840x2160 when streaming. It doesn't even seem to matter what DSR options are selected, it just has to be enabled. Without it enabled, I get weird behavior like not seeing 3840x2160 as an option in the nvidia control panel, or games zooming in and cropping the image when selecting 4k.

michaeldperlo commented 1 year ago

Here’s a link to Playnite w GameStream Launchpad in case you’re curious! https://playnite.link/forum/thread-403.html


From: hansschmucker @.> Sent: Tuesday, July 19, 2022 3:03:04 PM To: moonlight-stream/moonlight-qt @.> Cc: michaeldperlo @.>; Comment @.> Subject: Re: [moonlight-stream/moonlight-qt] Automatically switch resolution when starting a stream (ideal for Ultrawide users) (Issue #784)

It's not ideal, but I've written a little utility which you can download over at https://github.com/hansschmucker/NVStreamer1080/releases/tag/v1.0.0.0 What it does is either switch to a second screen or set the current one to 1920x1080/60 whenever nvstreamer is active and return to the previous setup afterwards.

It automatically adds itself to the autostart and runs in background... I've been running this for a year or so and it works pretty well for me.

For my home setup I've added a 1080p HDMI dummy and use the utility to switch to that screen... which actually is necessary in my case since NVidia still has a bug where you can't gamestream while connected to a DisplayPort screen if that screen isn't turned on and well, mine usually is off.

— Reply to this email directly, view it on GitHubhttps://github.com/moonlight-stream/moonlight-qt/issues/784#issuecomment-1189594974, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZGL7ZWXYPAYG5HCAPNENQLVU4QZRANCNFSM5USAUINA. You are receiving this because you commented.Message ID: @.***>

ewanotoole commented 1 year ago

@hansschmucker hey! this is a really cool tool. Would it be possible to add a customer return refresh rate? It picks up my correct return resolution but keeps the 60hz when going back from gamemode. Otherwise this does exactly what I need!

bashbers commented 1 year ago

@ewanotoole That's weird, it correctly switches between 120hz and 144hz for me when I exit moonlight..

hansschmucker commented 1 year ago

@ewanotoole Definitely possible. Could you please file an issue... don't have much spare time right now and I keep forgetting stuff ^^ .

hansschmucker commented 1 year ago

@ewanotoole got around to doing it. Have a look at v1.1.1.0 :)

Vegz78 commented 1 year ago

@ewanotoole got around to doing it. Have a look at v1.1.1.0 :)

Thanks for a great tool, @hansschmucker!!! Saved me a ton of time, frustration and headache after I got a new 1980x1200 host screen and most Moonlight clients streaming the desktop in 1980x1080@60!... ;-)

nem8 commented 1 year ago

@ewanotoole got around to doing it. Have a look at v1.1.1.0 :)

This seems to be exactly what I need as I have an ultra wide on my desktop. Thanks for sharing, I will give it a try.

liamharper2453 commented 1 year ago

Hi, thought I would add to this based on my experience. I have a 3440x1440 100hz ultrawide monitor trying to change resolution and stream to my LG CX TV at a desired 3840x2160 100hz.

I have tried both applications suggested above in the discussion but none worked for me unfortunately.

I always had either:

For me what finally worked was using:

https://tools.taubenkorb.at/change-screen-resolution/

I personally use Playnite, so in Playnite there are options to run things on application start up and shut down (I am sure you could also put a .bat file together or something if you don’t use Playnite specifically). Using the linked application along with Playnite finally gave me a seamless experience.

ahmadalli commented 1 year ago

If you're using Sunshine, you can utilize Do Command and Undo Command to automate this. They also provided the required commands on their docs.

fredsvanelli commented 9 months ago

Solution (Windows host only):

For this example, I'm using a 5120x1440 super ultra wide monitor. And I want to stream my games at 1920x1080.

itsdinkd commented 4 months ago

Solution (Windows host only):

For this example, I'm using a 5120x1440 super ultra wide monitor. And I want to stream my games at 1920x1080.

  • Download QRes.exe (Google it)
  • Save it to an easy path. Ex: C:\Users\YOUR_USER\QRes.exe
  • When adding the game to Sunshine, Click on "+ Add Commands"
  • Add this on Do command:
C:\Users\YOUR_USER\QRes.exe /x:1920 /y:1080

This will change the Windows screen resolution to 1920x1080 when opening the game

  • Add this on Undo command:
C:\Users\YOUR_USER\QRes.exe /x:5120 /y:1440

This will change back the resolution to 5120x1440 when closing the game

You can also add /r:{{FPS HERE}} ie; /r:165 (if you want to go to 165hz fps) you can add this to both DO and UNDO.

Sunshine added to docs another method based on what you set your client config to image

snipem commented 3 months ago

In case anyone is interested: I made a program that will automatically activate and deactivate your fake (IddSampleDriver) and main display if Sunshine is streaming.

I use this to match odd 16:10 resolutions that my ultra wide monitor is not supporting: https://github.com/snipem/moonlight_display_auto_switch