obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
657 stars 95 forks source link

SetRecordingFolder not working #332

Open abenmohamed opened 1 year ago

abenmohamed commented 1 year ago

Hi, I'm currently facing an issue while attempting to set the recording folder using the OBS WebSocket API. I'm receiving the following error message: OBSWebSocketError: Your request type is not valid.

According to the documentation, the SetRecordDirectory method was introduced in version v5.3.0 of obs-websocket. However, the latest available version of obs-websocket is 5.2.3, which does not include this method.

I have also tried using the GetRecordDirectory method, but it does not return the desired value for my use case. Specifically, I need to retrieve the URL when using Custom Output (Ffmpeg) with the output type set to "Output to URL". Currently, the method only returns the value when the output type is set to "Output to File".

Note: Since the latest version of obs-websocket (5.2.3) does not include the SetRecordDirectory method, I would appreciate any guidance or suggestions for a workaround to achieve my desired outcome of setting the recording folder with the specified output type.

SpaceBod commented 10 months ago

@abenmohamed , in case you still need a solution:

Since OBS Studio currently doesn't have v5.3.0 implemented, you can't use SetRecordDirectory, you can use the old method's SetProfileParameter:

This is for JavaScript

// Sets a new recording path
obs.call('SetProfileParameter', { 'parameterCategory': 'SimpleOutput', 'parameterName': 'FilePath', 'parameterValue': selectedFolderPath })

// Prints the now changed values
obs.call('GetProfileParameter', { 'parameterCategory': 'SimpleOutput', 'parameterName': 'FilePath' })
    .then(result => {
        console.log('Result:', result);
    })
    .catch(error => {
        console.error('Error:', error);
    });

What worked for me was setting: parameterCategory -> "SimpleOutput" parameterName -> "FilePath"

Similarly you can change the output type. You can change these variables:

[SimpleOutput] FilePath="path goes here" RecFormat2=mkv VBitrate=2500 ABitrate=160 UseAdvanced=false Preset=veryfast NVENCPreset2=p5 RecQuality=Small RecRB=false RecRBTime=20 RecRBSize=512 RecRBPrefix=Replay StreamAudioEncoder=aac RecAudioEncoder=aac RecTracks=1 StreamEncoder=nvenc RecEncoder=nvenc