From 9e22e6e1c8029c41f2bf786198f8078f344b6453 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 20 Aug 2024 17:41:42 +0200 Subject: [PATCH] use obs shadowplay --- .config/obs/ReplayBuffer.json | 235 ++++++++++++++++++++ .config/obs/ReplayBuffer/basic.ini | 119 ++++++++++ .config/obs/ReplayBuffer/streamEncoder.json | 1 + Makefile | 4 +- windows/fix_obs_shortcut.bat | 20 -- windows/start_obs_as_shadowplay.bat | 19 ++ windows11.bat | 31 +-- 7 files changed, 393 insertions(+), 36 deletions(-) create mode 100644 .config/obs/ReplayBuffer.json create mode 100644 .config/obs/ReplayBuffer/basic.ini create mode 100644 .config/obs/ReplayBuffer/streamEncoder.json delete mode 100644 windows/fix_obs_shortcut.bat create mode 100644 windows/start_obs_as_shadowplay.bat diff --git a/.config/obs/ReplayBuffer.json b/.config/obs/ReplayBuffer.json new file mode 100644 index 0000000..0b80a27 --- /dev/null +++ b/.config/obs/ReplayBuffer.json @@ -0,0 +1,235 @@ +{ + "DesktopAudioDevice1": { + "prev_ver": 503447555, + "name": "Audio du bureau", + "uuid": "bd19a8ef-aee4-4725-92b0-8a1d2ab917a1", + "id": "wasapi_output_capture", + "versioned_id": "wasapi_output_capture", + "settings": { + "device_id": "default" + }, + "mixers": 251, + "sync": 0, + "flags": 0, + "volume": 1.0, + "balance": 0.5, + "enabled": true, + "muted": false, + "push-to-mute": false, + "push-to-mute-delay": 0, + "push-to-talk": false, + "push-to-talk-delay": 0, + "hotkeys": { + "libobs.mute": [], + "libobs.unmute": [], + "libobs.push-to-mute": [], + "libobs.push-to-talk": [] + }, + "deinterlace_mode": 0, + "deinterlace_field_order": 0, + "monitoring_type": 0, + "private_settings": {} + }, + "AuxAudioDevice1": { + "prev_ver": 503447555, + "name": "Mic/Aux", + "uuid": "b72a6bee-252d-4ab5-833e-46bbc4864f76", + "id": "wasapi_input_capture", + "versioned_id": "wasapi_input_capture", + "settings": { + "device_id": "default" + }, + "mixers": 253, + "sync": 0, + "flags": 2, + "volume": 1.4125375747680664, + "balance": 0.5, + "enabled": true, + "muted": false, + "push-to-mute": false, + "push-to-mute-delay": 0, + "push-to-talk": false, + "push-to-talk-delay": 0, + "hotkeys": { + "libobs.mute": [], + "libobs.unmute": [], + "libobs.push-to-mute": [], + "libobs.push-to-talk": [] + }, + "deinterlace_mode": 0, + "deinterlace_field_order": 0, + "monitoring_type": 0, + "private_settings": {} + }, + "current_scene": "Scène", + "current_program_scene": "Scène", + "scene_order": [ + { + "name": "Scène" + } + ], + "name": "ReplayBuffer", + "groups": [], + "quick_transitions": [ + { + "name": "Coupure", + "duration": 300, + "hotkeys": [], + "id": 1, + "fade_to_black": false + }, + { + "name": "Fondu", + "duration": 300, + "hotkeys": [], + "id": 2, + "fade_to_black": false + }, + { + "name": "Fondu", + "duration": 300, + "hotkeys": [], + "id": 3, + "fade_to_black": true + } + ], + "transitions": [], + "saved_projectors": [], + "current_transition": "Fondu", + "transition_duration": 300, + "preview_locked": false, + "scaling_enabled": false, + "scaling_level": 0, + "scaling_off_x": 0.0, + "scaling_off_y": 0.0, + "virtual-camera": { + "type2": 3 + }, + "modules": { + "scripts-tool": [], + "output-timer": { + "streamTimerHours": 0, + "streamTimerMinutes": 0, + "streamTimerSeconds": 30, + "recordTimerHours": 0, + "recordTimerMinutes": 0, + "recordTimerSeconds": 30, + "autoStartStreamTimer": false, + "autoStartRecordTimer": false, + "pauseRecordTimer": true + }, + "auto-scene-switcher": { + "interval": 300, + "non_matching_scene": "", + "switch_if_not_matching": false, + "active": false, + "switches": [] + }, + "captions": { + "source": "", + "enabled": false, + "lang_id": 1036, + "provider": "mssapi" + } + }, + "sources": [ + { + "prev_ver": 503447555, + "name": "Capture d'écran", + "uuid": "62ecad8b-28d0-48f4-a0ef-b6952f9c1de7", + "id": "monitor_capture", + "versioned_id": "monitor_capture", + "settings": { + "monitor_id": "\\\\?\\DISPLAY#AOC2590#5&243f34f&2&UID155906#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}" + }, + "mixers": 0, + "sync": 0, + "flags": 0, + "volume": 1.0, + "balance": 0.5, + "enabled": true, + "muted": false, + "push-to-mute": false, + "push-to-mute-delay": 0, + "push-to-talk": false, + "push-to-talk-delay": 0, + "hotkeys": {}, + "deinterlace_mode": 0, + "deinterlace_field_order": 0, + "monitoring_type": 0, + "private_settings": {} + }, + { + "prev_ver": 503447555, + "name": "Scène", + "uuid": "0b53bf55-6a71-4b86-960a-f2df1c2e0c3d", + "id": "scene", + "versioned_id": "scene", + "settings": { + "id_counter": 1, + "custom_size": false, + "items": [ + { + "name": "Capture d'écran", + "source_uuid": "62ecad8b-28d0-48f4-a0ef-b6952f9c1de7", + "visible": true, + "locked": false, + "rot": 0.0, + "pos": { + "x": 0.0, + "y": 0.0 + }, + "scale": { + "x": 1.0, + "y": 1.0 + }, + "align": 5, + "bounds_type": 0, + "bounds_align": 0, + "bounds_crop": false, + "bounds": { + "x": 0.0, + "y": 0.0 + }, + "crop_left": 0, + "crop_top": 0, + "crop_right": 0, + "crop_bottom": 0, + "id": 1, + "group_item_backup": false, + "scale_filter": "disable", + "blend_method": "default", + "blend_type": "normal", + "show_transition": { + "duration": 0 + }, + "hide_transition": { + "duration": 0 + }, + "private_settings": {} + } + ] + }, + "mixers": 0, + "sync": 0, + "flags": 0, + "volume": 1.0, + "balance": 0.5, + "enabled": true, + "muted": false, + "push-to-mute": false, + "push-to-mute-delay": 0, + "push-to-talk": false, + "push-to-talk-delay": 0, + "hotkeys": { + "OBSBasic.SelectScene": [], + "libobs.show_scene_item.1": [], + "libobs.hide_scene_item.1": [] + }, + "deinterlace_mode": 0, + "deinterlace_field_order": 0, + "monitoring_type": 0, + "private_settings": {} + } + ] +} \ No newline at end of file diff --git a/.config/obs/ReplayBuffer/basic.ini b/.config/obs/ReplayBuffer/basic.ini new file mode 100644 index 0000000..6e5e2dd --- /dev/null +++ b/.config/obs/ReplayBuffer/basic.ini @@ -0,0 +1,119 @@ +[General] +Name=ReplayBuffer + +[Output] +Mode=Advanced +FilenameFormatting=%CCYY-%MM-%DD %hh-%mm-%ss +DelayEnable=false +DelaySec=20 +DelayPreserve=true +Reconnect=true +RetryDelay=2 +MaxRetries=25 +BindIP=default +IPFamily=IPv4+IPv6 +NewSocketLoopEnable=false +LowLatencyEnable=false + +[Stream1] +IgnoreRecommended=false +EnableMultitrackVideo=false +MultitrackVideoMaximumAggregateBitrateAuto=true +MultitrackVideoMaximumVideoTracksAuto=true + +[SimpleOutput] +FilePath=C:\\Users\\anri\\Videos +RecFormat2=mkv +VBitrate=2500 +ABitrate=160 +UseAdvanced=false +Preset=veryfast +NVENCPreset2=p5 +RecQuality=Stream +RecRB=false +RecRBTime=20 +RecRBSize=512 +RecRBPrefix=Replay +StreamAudioEncoder=aac +RecAudioEncoder=aac +RecTracks=1 +StreamEncoder=nvenc +RecEncoder=nvenc + +[AdvOut] +ApplyServiceSettings=true +UseRescale=false +TrackIndex=1 +VodTrackIndex=2 +Encoder=obs_x264 +RecType=Standard +RecFilePath=C:\\Users\\anri\\Videos +RecFormat2=fragmented_mp4 +RecUseRescale=false +RecTracks=7 +RecEncoder=none +FLVTrack=1 +StreamMultiTrackAudioMixes=1 +FFOutputToFile=true +FFFilePath=C:\\Users\\anri\\Videos +FFVBitrate=2500 +FFVGOPSize=250 +FFUseRescale=false +FFIgnoreCompat=false +FFABitrate=160 +FFAudioMixes=1 +Track1Bitrate=320 +Track2Bitrate=320 +Track3Bitrate=320 +Track4Bitrate=160 +Track5Bitrate=160 +Track6Bitrate=160 +RecSplitFileTime=15 +RecSplitFileSize=2048 +RecRB=true +RecRBTime=120 +RecRBSize=512 +AudioEncoder=ffmpeg_aac +RecAudioEncoder=ffmpeg_aac +RecSplitFileType=Time +FFFormat= +FFFormatMimeType= +FFVEncoderId=0 +FFVEncoder= +FFAEncoderId=0 +FFAEncoder= +Track1Name=System sounds and microphone +Track2Name=System sounds +Track3Name=Microphone +FFExtension=mp4 + +[Video] +BaseCX=1920 +BaseCY=1080 +OutputCX=1280 +OutputCY=720 +FPSType=0 +FPSCommon=30 +FPSInt=30 +FPSNum=30 +FPSDen=1 +ScaleType=bicubic +ColorFormat=NV12 +ColorSpace=709 +ColorRange=Partial +SdrWhiteLevel=300 +HdrNominalPeakLevel=1000 + +[Audio] +MonitoringDeviceId=default +MonitoringDeviceName=Par défaut +SampleRate=48000 +ChannelSetup=Stereo +MeterDecayRate=23.53 +PeakMeterType=0 + +[Panels] +CookieId=5C49A2560FAAB895 + +[Hotkeys] +ReplayBuffer={"ReplayBuffer.Save":[]} diff --git a/.config/obs/ReplayBuffer/streamEncoder.json b/.config/obs/ReplayBuffer/streamEncoder.json new file mode 100644 index 0000000..45aa406 --- /dev/null +++ b/.config/obs/ReplayBuffer/streamEncoder.json @@ -0,0 +1 @@ +{"bitrate":8000,"use_bufsize":false} \ No newline at end of file diff --git a/Makefile b/Makefile index a32ba54..9ab9617 100644 --- a/Makefile +++ b/Makefile @@ -192,7 +192,7 @@ sync-windows: @$(WGET) $(REPO_SRC)/windows/installers/vencord.bat -O $(WIN_HOME)/Documents/Local/vencord_installer.bat @$(WGET) $(REPO_SRC)/windows/fix_nvidia_wsl.bat -O $(WIN_HOME)/Documents/Local/fix_nvidia_wsl.bat @$(WGET) $(REPO_SRC)/windows/fix_mihoyo_shortcut.bat -O $(WIN_HOME)/Documents/Local/fix_mihoyo_shortcut.bat -# @$(WGET) $(REPO_SRC)/windows/fix_obs_shortcut.bat -O $(WIN_HOME)/Documents/Local/fix_obs_shortcut.bat + @$(WGET) $(REPO_SRC)/windows/start_obs_as_shadowplay.bat -O $(LOCALAPPDATA)/start_obs_as_shadowplay.bat @echo "$(WIN) Scripts synced!" @echo @@ -202,7 +202,7 @@ sync-windows: $(WGET) $(REPO_SRC)/games/cs2/myconfig.cfg -O $(CS2_CFG)/myconfig.cfg; \ $(WGET) $(REPO_SRC)/games/cs2/customgame.cfg -O $(CS2_CFG)/customgame.cfg; \ $(WGET) $(REPO_SRC)/games/cs2/normalgame.cfg -O $(CS2_CFG)/normalgame.cfg; \ - echo "$(WIN) CS2 scripts synced!"; \ + echo "$(WIN) CS2 configs synced!"; \ echo; \ fi # Firefox diff --git a/windows/fix_obs_shortcut.bat b/windows/fix_obs_shortcut.bat deleted file mode 100644 index 07a745a..0000000 --- a/windows/fix_obs_shortcut.bat +++ /dev/null @@ -1,20 +0,0 @@ -@ECHO OFF - -:: Start as administrator -fltmc >NUL 2>&1 || ( - PowerShell Start -Verb RunAs '%0' 2>NUL || ( - EXIT 1 - ) - EXIT 0 -) - -PowerShell -Command "" ^ - "$WshShell = New-Object -COM WScript.Shell;" ^ - "$Shortcut = $WshShell.CreateShortcut('%ProgramData%\Microsoft\Windows\Start Menu\Programs\OBS Studio\OBS Studio (64bit).lnk');" ^ - "$Shortcut.TargetPath = '%ProgramFiles%\obs-studio\bin\64bit\obs64.exe';" ^ - "$Shortcut.WorkingDirectory = '%ProgramFiles%\obs-studio\bin\64bit';" ^ - "$Shortcut.Arguments = '--profile ""ANRI GAMING (PROFIL)"""" --multi';" ^ - "$Shortcut.Save()" - -IF NOT "%1"=="yes" PAUSE -EXIT /B diff --git a/windows/start_obs_as_shadowplay.bat b/windows/start_obs_as_shadowplay.bat new file mode 100644 index 0000000..beb9f5d --- /dev/null +++ b/windows/start_obs_as_shadowplay.bat @@ -0,0 +1,19 @@ +@ECHO OFF + +:: Start as administrator +fltmc >NUL 2>&1 || ( + PowerShell Start -Verb RunAs '%0' 2>NUL || ( + EXIT 1 + ) + EXIT 0 +) + +:: Working directory +CD "%ProgramFiles%\obs-studio\bin\64bit" + +:: Run OBS +START "OBS Shadowplay batch wrapper" ^ + obs64.exe --portable --minimize-to-tray --disable-missing-files-check \ + --profile "ReplayBuffer" --scene "ReplayBuffer" --startreplaybuffer + +EXIT /B diff --git a/windows11.bat b/windows11.bat index 54d135c..7d685f1 100644 --- a/windows11.bat +++ b/windows11.bat @@ -25,7 +25,7 @@ fltmc >NUL 2>&1 || ( PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/vencord.bat -OutFile '!local!\vencord_installer.bat'" PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/fix_nvidia_wsl.bat -OutFile '!local!\fix_nvidia_wsl.bat'" PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/fix_mihoyo_shortcut.bat -OutFile '!local!\fix_mihoyo_shortcut.bat'" - :: PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/fix_obs_shortcut.bat -OutFile '!local!\fix_obs_shortcut.bat'" + PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/start_obs_as_shadowplay.bat -OutFile '%LOCALAPPDATA%\start_obs_as_shadowplay.bat'" :: === Install Spotify == @@ -363,19 +363,22 @@ PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/WindowsAutoNightMode/ :: === OBS == -:: TODO: Replaced by NVidia Shadowplay -:: OBS replay buffer at startup -:: PowerShell -Command "$WshShell = New-Object -COM WScript.Shell;" ^ -:: "$Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\OBS.lnk');" ^ -:: "$Shortcut.TargetPath = '%ProgramFiles%\obs-studio\bin\64bit\obs64.exe';" ^ -:: "$Shortcut.WorkingDirectory = '%ProgramFiles%\obs-studio\bin\64bit';" ^ -:: "$Shortcut.Arguments = '--disable-missing-files-check --minimize-to-tray " ^ -:: "--startreplaybuffer --profile ""ReplayBuffer"""" --scene ""ReplayBuffer""""';" ^ -:: "$Shortcut.Save()" -:: :: Default shortcut should start default profile -:: CALL "!local!\fix_obs_shortcut.bat" yes -:: :: Allow system to go in sleep mode when OBS is running -:: powercfg -requestsoverride process obs64.exe display system awaymode +MKDIR "%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer" 2>NUL +PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/ReplayBuffer/basic.ini -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer\basic.ini'" +PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/ReplayBuffer/streamEncoder.json -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer\streamEncoder.json'" + +MKDIR "%ProgramFiles%\obs-studio\config\obs-studio\basic\scenes" 2>NUL +PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/ReplayBuffer.json -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\scenes\ReplayBuffer.json'" + +SCHTASKS /Create /TN "OBS Shadowplay" ^ + /TR "'%LOCALAPPDATA%\start_obs_as_shadowplay.bat'" ^ + /SC ONSTART ^ + /RU "%USERNAME%" ^ + /RL HIGHEST ^ + /F + +:: Allow system to go in sleep mode when OBS is running +POWERCFG /REQUESTSOVERRIDE PROCESS obs64.exe DISPLAY SYSTEM AWAYMODE :: === miHoYo Games launcher ==