Question / Help Start in Full Screen Preview

Strykt

New Member
Hello!

I've searched Google and these forums, but haven't been able to find an exact answer. I'm using OBS on a video monitoring system to add an overlay to a bunch of window displays. It works great. Now, there is another vms board that's been set up differently than what I'm used to. Basically, it restarts each and every morning and then runs a script to start up some programs automatically.

My goal is to have OBS start up automatically and run itself into full screen preview. I've found instructions for having it run at start up, but I haven't figured out a command line script or process to have it go into full screen preview immediately. Setting this up manually at startup isn't an option, if anyone remote accesses the PC, the external display locks itself until the PC is restarted again.

Thanks for reading and any ideas you might have!

-Josh
 

koala

Active Member
Go to settings->General->Projectors and activate "Save projectors on exit". Open your desired projector(s), close OBS to save the state of all opened projectors. Then open OBS again and all projectors that were active at the graceful termination of OBS will come up again.
 

PEM

New Member
Ok, but no idea to do that everytime. Because if you close the projector window to shutdown, it won't go full screen at next start up
 

carlmmii

Active Member
Ah, so you're running the projector over the same window as OBS is running on?

Try getting everything set up, then shutting your computer down using the power button (don't hold, just press it once to activate normal windows shutdown). This will hopefully force OBS to close nicely, and save the projector settings.
 

gregers

New Member
Unfortunately in OBS 23.2.1 Linux it doesn't work.
Anyway there is an easy method to start OBS in fullscreen preview mode using xdotool:

#!/bin/bash.
pkill obs
obs&
sleep 10
WID=`xdotool search --name "OBS"`
echo $WID
xdotool windowfocus $WID.
xdotool mousemove --window $WID 0 0
xdotool mousemove --window $WID 100 100
xdotool click --window $WID 3
xdotool key Down Down Down Down Right Return
 

zen85

New Member
Unfortunately in OBS 23.2.1 Linux it doesn't work.
Anyway there is an easy method to start OBS in fullscreen preview mode using xdotool:

#!/bin/bash.
pkill obs
obs&
sleep 10
WID=`xdotool search --name "OBS"`
echo $WID
xdotool windowfocus $WID.
xdotool mousemove --window $WID 0 0
xdotool mousemove --window $WID 100 100
xdotool click --window $WID 3
xdotool key Down Down Down Down Right Return

very interessting... but isn't there a cleaner way? i see a lot of forum entries requesting this and there is a lot of potencial uses and it seems that this could be integrated very easily since the functionality is evidently here. just the needed manual intervention is really a bummer.

the rest of my obs setup is setup with websockets and a selfmade webinterface. i dont need the gui at all. i want to run it on a rpi4 which works fine as long as there is no transcoding involved.
 

johnzw

New Member
What works for me: I'm using obs-websocket to automatically open the projector in full screen mode (refer to protocol.md for documentation of this function). I'm using a small Python script that runs automatically on start-up (on the Windows machine by placing a link to python.exe <scriptname> in C:\Users\[User Name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup). The script looks like this:
Python:
import asyncio
import simpleobsws
import time

loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', password='', port=4444, loop=loop)

async def make_request():
    await ws.connect()

    data = {'geometry':'AdnQywACAAAAAAAAAAAAAAAAB38AAAQ3AAAACAAAAB8AAAeHAAAEQwAAAAAABAAAB4A='} # fullscreen
    result = await ws.call('OpenProjector', data)
   
    await ws.disconnect()

time.sleep(10) # wait ten seconds to make sure OBS has been started appropriately
loop.run_until_complete(make_request())

For finding the appropriate (base64 encoded) geometry string, I exported the scene collection in OBS while the fullscreen projector preview was active. The resulting .json-file then contained the geometry string that worked like a charm.
 
Last edited:

BenAndo

Member
What works for me: I'm using obs-websocket to automatically open the projector in full screen mode (refer to protocol.md for documentation of this function). I'm using a small Python script that runs automatically on start-up (on the Windows machine by placing a link to python.exe <scriptname> in C:\Users\[User Name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup). The script looks like this:
Python:
import asyncio
import simpleobsws
import time

loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', password='', port=4444, loop=loop)

async def make_request():
    await ws.connect()

    data = {'geometry':'AdnQywACAAAAAAAAAAAAAAAAB38AAAQ3AAAACAAAAB8AAAeHAAAEQwAAAAAABAAAB4A='} # fullscreen
    result = await ws.call('OpenProjector', data)
  
    await ws.disconnect()

time.sleep(10) # wait ten seconds to make sure OBS has been started appropriately
loop.run_until_complete(make_request())

For finding the appropriate (base64 encoded) geometry string, I exported the scene collection in OBS while the fullscreen projector preview was active. The resulting .json-file then contained the geometry string that worked like a charm.
Hey johnzw, I'd love for this to work for me as sometimes people close the OBS Multiview window before closing OBS. This then makes it not auto-open the multiview next time OBS opens. I've installed Python 3.9 for Windows. I've got OBS Websockets enabled. I created a python files called test.py and pasted in your code. However, when I launch the script the command prompt briefly shows up and then disappears. Is there something I'm missing?
 

BenAndo

Member
Actually I got it to work, sort of. I've never really used Python before. After installing simpleobsws it worked. I was able to modify it to open as a multiview type. Here is my code:
Python:
import asyncio
import simpleobsws
import time

loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', password='', port=4444, loop=loop)

async def make_request():
    await ws.connect()
    
    data = {'geometry':'AdnQywACAAAAAAAAAAAAAAAAB38AAAQ3AAAACAAAAB8AAAeHAAAEQwAAAAAABAAAB4A='} # fullscreen   
    data = {'type':'Multiview'} 
    result = await ws.call('OpenProjector', data)
  
    await ws.disconnect()

time.sleep(2) # wait two seconds to make sure OBS has been started appropriately
loop.run_until_complete(make_request())

I can't get it to fullscreen though. Does anyone know how to fullscreen it?
 

DF3EI

New Member
Are there any resources on how to assemble the geometry string programmatically? Not the Base64 encoding, but what the object looks like that is being encoded.
 

FabianMM

New Member
After a little trial and error, I have now been able to display the studio program in full screen. It will probably work with multiview too.
Thanks for the Code johnzw

Python:
import asyncio
import simpleobsws
import time

loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', password='', port=4444, loop=loop)

async def make_request():
    await ws.connect()

    data = {'geometry':'AdnQywACAAAAAAAAAAAAAAAAB38AAAQ3AAAACAAAAB8AAAeHAAAEQwAAAAAABAAAB4A=', 'type':'StudioProgram'} # fullscreen & StudioProgram
    result = await ws.call('OpenProjector', data)
  
    await ws.disconnect()

time.sleep(10) # wait ten seconds to make sure OBS has been started appropriately
loop.run_until_complete(make_request())
 

Barabba

Member
Hi mates, I've read the problem here is under Linux, there is any way to start full screen preview in Windows? Thank you
 

FabianMM

New Member
Hi Barabba
You can Run the Python script in Windows. It works.
If you want the preview as fullscreen you have to change the type from "StudioProgram" to "Preview".
 

Barabba

Member
thank you for you kind answer :)
I've never ran a python script, How can I do it under Windows? May you please briefly tell step by step? Thanks!

I guess, install Python, save the script as txt file, rename txt on something executable by pyton and place it in the scheduler (boot)
 

johanG

New Member
I eventually found a solution for this and hopefully it can help someone in the future who don't want to write Python code.

I created a small NodeJs application which allows me to communicate with OBS.
With the help of this Javascript library I could easily tell OBS to go into full screen mode when the Node application starts.
https://github.com/haganbmj/obs-websocket-js

In order for this to work you need to install the one of latest versions of obs-websocket.
Older versions below v4.8.0 won’t work. It also requires OBS v24.0.4 or newer.
https://github.com/Palakis/obs-websocket/releases/tag/4.9.0

Here is the documentation on how to use it:
https://github.com/Palakis/obs-websocket/blob/4.8.0/docs/generated/protocol.md#openprojector

Below you will find a snippet of how I tell OBS to start a Fullscreen Projection (Preview) on the only connected monitor (0).

Code:
udpPort.on("ready", function () {

    // set a short delay to make sure the socket connection is made before calling
    setTimeout(() => {
     return obs.send("OpenProjector", {
              'type': "Preview",
              'monitor': 0
     }).catch((err) => {
             console.log(`ERROR: ${err.error}`);
     });
    }, 2000);
});
 

mw46d

New Member
OK, I just stumbled into the same issue. I wanted to auto-start a Halloween display;-) So, here is my little OBS-Python version. It does not do anything but waiting 10 seconds and starting a full screen preview.
Python:
import obspython as obs

# ------------------------------------------------------------

def start_preview_projector_cb():
        obs.obs_frontend_open_projector("Preview", 0, "AdnQywACAAAAAAAAAAAAAAAAB38AAAQ3AAAACAAAAB8AAAeHAAAEQwAAAAAABAAAB4A=", "")
        obs.remove_current_callback()

# ------------------------------------------------------------

def script_description():
        return "Start the preview in full screen mode on display 1"

def script_update(settings):
        startup_seconds = obs.obs_data_get_int(settings, "startup_seconds")

        obs.timer_remove(start_preview_projector_cb)
        obs.timer_add(start_preview_projector_cb, startup_seconds * 1000)

def script_defaults(settings):
        obs.obs_data_set_default_int(settings, "startup_seconds", 10)

def script_properties():
        props = obs.obs_properties_create()
        obs.obs_properties_add_int(props, "startup_seconds", "Time needed for OBS startup (seconds)", 5, 3600, 1)

        return props
Just save it as some Python file, and in OBS: Tools-> Scripts -> Load your file and close & restart OBS. After 10 seconds, the preview projector should start.

I hope, this might be useful for some;-)
 
Top