Documentation for obs-codec-test.ahxk Required script processor: Autohotkey - http://ahkscript.org/ ------------------------------------------------------------------------------- General description obs-encode-test.ahk is a Autohotkey script that automates recordings in OBS for testing and comparison purposes. It is also able to perform certain analysis on the created videos with ffmpeg to create some kind of rating of the video quality. In the script, you define OBS settings you want to use for recording, and the script will configure OBS automatically and do the recording. This way, you can record the same source multiple times with different encoder settings, so you can compare the resulting videos with themselves. There is no config file for the script. You configure it by editing the initialization section of the script itself. For this, load obs-encode-test.ahk into your favorite text editor. After editing the script, you must reload it, if you started it previously. ------------------------------------------------------------------------------- Contents 1. CONCEPT 2. GENERAL SETUP 3. RECORDING TEST VIDEOS 4. ANALYZING TEST VIDEOS 5. RATING TEST VIDEOS 6. SUGGESTED WORKFLOW A. PRODUCING THE LOSSLESS REFERENCE VIDEOS ------------------------------------------------------------------------------- 1. CONCEPT The first step in the process is to record videos with different encoder settings. The video source is a lossless reference video that is the same for every recording. The second step is to perform analyis on the existing video files. The third step is to compare the analysis and produce a rating. The steps are invoked independently from each other, so you can stop any process any time and start where you left, and you can remove and redo a video before analysis. Or you can manually add videos you got from other sources and feed them into the analysis. Of course every video must be recorded from the same reference video. ------------------------------------------------------------------------------- 2. GENERAL SETUP 2.0 you need ffmpeg. The script requires ffmpeg.exe callable from the command line. Install it and add it to your Windows PATH, if you don't have it installed yet. Get it from here: https://ffmpeg.zeranoe.com/builds/ 2.1. for each resolution and fps, you need a source video with exactly the resolution and fps you want to test. Don't let OBS scale, because it's the encoder quality we want to test, not the scaling quality of OBS. How to produce the source video(s), see chapter A. 2.2. choose a base directory for your source videos and put the source videos and the 2 png files into a directory structure like this: in obs-encode-test.ahk, enter your desired path: global BaseRefDir := "C:\Users\alex\Documents\Videos" Directory structure: C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720.avi C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720 high motion.png C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720 low motion.png C:\Users\alex\Documents\Videos\1280x720\60\lossless 1280x720.avi C:\Users\alex\Documents\Videos\1280x720\60\lossless 1280x720 high motion.png C:\Users\alex\Documents\Videos\1280x720\60\lossless 1280x720 low motion.png C:\Users\alex\Documents\Videos\1920x1080\30\lossless 1920x1080.avi C:\Users\alex\Documents\Videos\1920x1080\30\lossless 1920x1080 high motion.png C:\Users\alex\Documents\Videos\1920x1080\30\lossless 1920x1080 low motion.png 2.3. choose a base directory for your generated video files It's mainly the same hierarchy, but you can (and should) choose a different base directory. in obs-encode-test.ahk, enter your desired path: global BaseDestDir := "D:\Dateien\Alex\Videos\Aufzeichnungen" 2.4. OBS configuration This is a onetime configuration, if you create a profile for your benchmarks. You MUST have OBS running on a monitor with 100% dpi scaling (that's the Windows default for desktop systems with 1920x1080 monitor resolution). Otherwise, the script will click not at the correct postions. - create a new scene you will use throughout the tests and call it "benchmark" - add to the scene one source of type "VLC Video Source". It is required that you have VLC installed. You don't need to add files to the video source playlist, this is done by the script automatically. - open OBS settings - click Stream tab - choose Twitch as streaming service. If you don't have a Twitch account, leave the stream key empty. We will not actually stream to Twitch, but this setting provides a default for some hidden encoder settings for simple output mode. - click Output tab - choose simple output mode - ensure that "Enable Advanced Encoder Settings" is checked, so you see the drop down list for "Encoder Preset (higher = less CPU)". - choose mp4 as recording format - ensure that "Generate File Name without Space" is NOT checked - choose advanced output mode - click on "Recording" to activate the recording settings - choose mp4 as recording format - ensure that only audio track 1 is checked. If you don't do this, the script will click the wrong positions. - ensure that "Generate File Name without Space" is NOT checked - click Advanced tab - make sure that the following settings are in place: (if you choose other settings, your results cannot be compared to the results of other people who also use this script to compare encoder quality) - Color Format: NV12 - YUV Color Space: 601 - YUV Color Range: Partial - make sure "Overwrite if file exists" is checked - click Hotkeys - add a hotkey for the action "Start Recording": CTRL-SHIFT-` (backtick) - add a hotkey for the action "Stop Recording": CTRL-SHIFT-` (backtick) - add a hotkey for the action benchmark -> Show "VLC Video Source": CTRL-ALT-V - add a hotkey for the action benchmark -> Hide "VLC Video Source": CTRL-ALT-V This way you toggle recording by pressing CTRL-SHIFT-` and toggle the source video with CTRL-ALT-V 2.5. Customizing the script to your PC The script must know what hardware your PC has, so it will not try to click on dropdown box entries for encoders or reate control settings your hardware doesn't provide. Look into the structure MachineCapability and add your PC with its capabilities. The computer name is taken from the Windows computername. Unfortunately, only Skylake/IvyBridge (for Quicksync) and Kepler/Pascal (for NVENC) is known, since the author of this script only owns this hardware. If your PC differ, the script has to be extended. Especially, if you have a AMD card with vce, the script will not work without first entering the positions and options of the VCE encoder into the script configuration structures. ------------------------------------------------------------------------------- 3. RECORDING TEST VIDEOS Prerequisites: - you did the GENERAL SETUP (Chapter 1) - you created a LOSSLESS REFERENCE VIDEO (Appendix A) - edit obs-encode-test.ahk and activate one of the line with your desired resolution and fps: global Conf := Conf1280x720p30 ;global Conf := Conf1280x720p60 ;global Conf := Conf1920x1080p30 ;global Conf := Conf1920x1080p60 Only one line must be active; all others must be commented out. - verify that BaseDestDir, BaseRefDir and VideoExt is set correctly - got to the test definitions, which start below the line "Tests.simple := {" and enter the desired attributes that should be permutated for each encoder and rate control There is a test definition for simple mode and for advanced mode If you only want to test one of the modes, bottom of the script and search for the line "DoTestMode("simple", tests.simple)". Activate/comment out the two calls to DoTestMode() according to what you want to do. - if you finished the configuration, double-click obs-encode-test.ahk, so a green "H" appears in your taskbar. Now the script sits passive in the taskbar and is waiting for you pressing its control hotkeys. If you already have the script running, press CTRL-ALT-R to reload the script, so it gets the current configuration. You will hear a sound when the script is reloaded this way. - start OBS if it is not already running. - to start the recording, press CTRL-ALT-G. The script will first perform some configuration in OBS magically and then start the recordings. If the script is clicking at the wrong places, immediately stop the script by either pressing CTRL-ALT-R (this stops and reloads it) or CTRL-ALT-X (this will stop it and you will be able to review the actions in the console window). - if the script finds that some videos already exist, it will skip these and continue with the next video. If you want to re-record a video, delete the *.mp4 file before you start the script. ------------------------------------------------------------------------------- 4. ANALYZING TEST VIDEOS Prerequisites: - you have some videos recorded, which you find in: \\ for example: D:\Dateien\Alex\Videos\Aufzeichnungen\1280x720\30\*.mp4 - you must have the reference video located in: \\\lossless .avi for example: C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720.avi - you must have prepared the high motion reference and low motion reference frames in the same directory as the reference video. For example: C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720 high motion.png C:\Users\alex\Documents\Videos\1280x720\30\lossless 1280x720 low motion.png - you must have ffmpeg installed (see 2. GENERAL SETUP) - press CTRL-ALT-H. The script will scan the videos in the abovementioned path. ------------------------------------------------------------------------------- 5. RATING TEST VIDEOS Prerequisites: - you recorded and analyzed your videos (4. ANALYZING TEST VIDEOS). The rating needs one file from the analysis: \\\