[Advanced+] Guide to scenes.xconfig [Scene cloning etc]

Sunspots

New Member
WARNING: The scenes.xconfig is not intended to be manipulated manually, wrong/broken syntax WILL give you problems!
The file is subject to change at any time without notice, which may break this guide, and/or your settings! I will try to keep this guide up to date but you can't necessarily rely on it.



What is scenes.xconfig?
All the settings for your scenes, their sources, as well as global sources are stored in a configuration file, called scenes.xconfig.
The scenes.xconfig file is essentially a text file containing nested associative arrays. The difference from most languages you may notice is that it does not use any quotation marks for strings, nor any commas between statements (I actually do not know what specific language this file is in.)

Why should I edit scenes.xconfig?
You probably shouldn't.
The reasons for editing scenes.xconfig would be:
  • Cloning a scene or source
  • Pixel-perfect adjustment of source frames.
  • Turning a local source into a global one

Before going any further, be sure that you are confident with what you are doing, if you encounter difficulties in understanding along in this guide, consider stepping back.
NOTE: Any scenes.xconfig editing needs to be done while OBS is turned off.
Where do I find scenes.xconfig?
The file is located in the OBS folder that you can find in your user AppData folder´.
The quickest way to do this is by entering the following in either a run-dialogue or in the explorer address field:
Code:
%APPDATA%\OBS
What are the contents of scenes.xconfig?
The file should contain two top-level objects, called "scenes" and "global sources" we will not be touching the "global sources" since there is generally nothing in there that we would want to edit manually (it is all directly available in the program).

What we want is the "scenes" object.

Inside the "scenes" object we can find scene-objects.
The syntax of a scene object is as follows(text with // in the beginning is comments):
Code:
  My Desktop : {                 // "My Desktop" is the name of the scene
    class : Scene                  // The class for this scene is always "Scene"
    sources : {              // This is the beginning of the "sources" object, see "sources"
      Desktop 1 : {               //  "Desktop 1" is the name of this scene
        class : DesktopImageSource       //  "DesktopImageSource" see "Source class" section
        data : {          // This is the beginning of the data object, see "data" section
          captureType : 0
          monitor : 0
          innerWindow : 1
          regionCapture : 0
          captureMouse : 1
          captureLayered : 0
          captureX : 0
          captureY : 0
          captureCX : 1920
          captureCY : 1080
          useColorKey : 0
          keyColor : -1
          keySimilarity : 10
          keyBlend : 0
          opacity : 100
        }
        cx : 1920      // This is the source width
        cy : 1080       // This is the source height
      }
      Cam : {
        class : GlobalSource // This object is loaded from a global source
        data : {
          name : Cam
        }
        cx : 322
        cy : 242
        x : 1598 // This is the source x position
        y : 838     // This is the source y position
      }
    }
  }

Sources
The sources object contains a set of source objects, the source objects in the example are called "Desktop 1" and "Cam"

Source Class
The class of a source determines what kind of source OBS will try to display. Common ones are GlobalSource, DesktopImageSource, GraphicsCapture, DeviceCapture etc.

Data
The data object contains a lot of data, what data it contains is all dependant on the source class. A GlobalSource source will for example only need one parameter - the name of the global source


How-to's

Clone a scene
To clone a scene, you need to isolate the scene object, it looks something like this:
Code:
My Scene : { 
    ...
}
All you need to do is copy the whole object and paste it just below it, or just before the end of the "scenes" object, make sure you include the right opening and closing brackets.

Clone a source
To clone a source, you need to isolate the scene object, it looks something like this:
Code:
My Source : { 
    ...
}
All you need to do is copy the whole object and paste it just below it, or just before the "hotkey" attribute in the end of the scene object, make sure you include the right opening and closing brackets.

Reposition or resize a source (This functionality will soon be available directly inside OBS)
Locate the source object you want and change the value of the "x" and "y" (for positioning) and/or the "cx" and "cy" (for size)

[Advanced] Turn a source into a Global Source
If you set up a source as a local source, but later if you want to reuse the source a lot, you can turn it into a global one.

Locate and copy the source just as you would when cloning a source.
But instead of pasting it inside the same scene object, you will need to locate the "global sources" object.
Paste in the source object just before the closing bracket of the "global sources" object.
If the source has "x" and "y" defined, you may want to remove those (I have not tested setting x and y on global sources, if it works, it may be useful if you want a global source to be positioned on a specific place by default)
 
Top