Envek / obs-studio-node-example

Learn how to use OBS Studio from your Electron app for screen video recording
GNU General Public License v2.0
99 stars 19 forks source link

Output to URL #28

Open julienjura opened 3 years ago

julienjura commented 3 years ago

Hello there !

I'm trying to capture & stream audio to an URL as provided in OBS-Studio. I've just cloned this minimal sample repo, rebuilt obs-studio-node from source, properly updated package.json and ran yarn install/start.

Electron is launching but won't send data to my URL (Icecast server) as set in basic.ini. I end up with the same situation when trying to set settings by myself in function configureOBS() (file obsRecorder.js)

I'm running this sample on a fresh Windows 10 install

Here's my basic.ini : `[Video] BaseCX=200 BaseCY=113 OutputCX=200 OutputCY=113 ScaleType=bicubic FPSCommon=60

[Audio] SampleRate=44100

[SimpleOutput] Mode=Simple VBitrate=2500 StreamEncoder=obs_x264 ABitrate=160 UseAdvanced=false FilePath=C:\Users\julien\Videos FileNameWithoutSpace=false RecQuality=Stream RecFormat=mp4 MuxerCustom= RecRB=true RecRBTime=20

[Output] Mode=Advanced

[AdvOut] TrackIndex=1 RecType=FFmpeg RecTracks=1 FLVTrack=1 FFOutputToFile=false FFURL=icecast://source:password@url:port/endpoint.ts FFFormat=mpegts FFFormatMimeType=video/MP2T FFExtension=ts FFVEncoderId=27 FFVEncoder=libx264 FFAEncoderId=86018 FFAEncoder=aac FFAudioMixes=1 FFVBitrate=25 FFVGOPSize=2 FFIgnoreCompat=true RescaleRes=1920x1080 RecRescaleRes=1920x1080 FFRescaleRes=140x80 FFABitrate=128 FFMCustom= FFRescale=true Encoder=obs_x264 ApplyServiceSettings=true Rescale=false RecFilePath=C:\Users\juju\Videos RecFileNameWithoutSpace=false RecFormat=flv RecEncoder=none RecRescale=false`

Here's my configureOBS() function ` function configureOBS() { console.debug('Configuring OBS'); setSetting('Output', 'Mode', 'Advanced');

setSetting('Output', 'TrackIndex', 1); setSetting('Output', 'RecType', 'FFmpeg'); setSetting('Output', 'RecTracks', 1); setSetting('Output', 'FLVTrack', 1); setSetting('Output', 'FFOutputToFile', 0); setSetting('Output', 'FFURL', 'icecast://source:password@url:port/endpoint.ts'); setSetting('Output', 'FFFormat', 'mpegts'); setSetting('Output', 'FFFormatMimeType', 'video/MP2T'); setSetting('Output', 'FFExtension', 'ts'); setSetting('Output', 'FFVEncoderId', 27); setSetting('Output', 'FFVEncoder', 'libx264'); setSetting('Output', 'FFAEncoderId', 86018); setSetting('Output', 'FFAEncoder', 'aac'); setSetting('Output', 'FFAudioMixes', 1); setSetting('Output', 'FFVBitrate', 25); setSetting('Output', 'FFVGOPSize', 2); setSetting('Output', 'FFIgnoreCompat', 1); setSetting('Output', 'RescaleRes', '1920x1080'); setSetting('Output', 'FFRescaleRes', '140x80'); setSetting('Output', 'FFABitrate', '140x80'); setSetting('Output', 'FFRescale', 1);

setSetting('Video', 'FPSCommon', 60);

console.debug('OBS Configured'); } `

Congrats for all this wonderfull piece of software ! Best regards

julienjura commented 3 years ago

Everything is working on OBS-Studio, i just want to replicate the correct settings in an test electron app through obs-studio-node

Envek commented 3 years ago

Don't change ini files directly, instead change configuration programmatically, as shown here: https://github.com/Envek/obs-studio-node-example/blob/e6268687c9eabcc50c063f9ef95f7e8abfc110ea/obsRecorder.js#L69-L77

Beware though, that API doesn't match configuration files format 1-to-1 and I believe that there is probably no docs for that. So, only trial and error and many experiments in debugger console.

Sorry, I can't help much there, I hadn't explored streaming.

julienjura commented 3 years ago

Hi Envek !

I tried this way yet but unsuccessfully. I'va posted my configureOBS() function

I'm using FFmpeg in OBS-Studio, so I tried : setSetting('Output', 'RecType', 'FFmpeg');

Maybe FFmpeg is a plugin or something else i need to place in specific location ?

I traced encoders returned by Only these are provided : const availableEncoders = getAvailableValues('Output', 'Recording', 'RecEncoder');

ENCODERS : none obs_x264 obs_qsv11 ffmpeg_nvenc jim_nvenc

xiaoyao316 commented 3 years ago

@julienjura Any progress? I was also plagued by the problem of pushing streams to the server, and I didn't know how to set it up because there was no docs.

hrueger commented 3 years ago

@julienjura @xiaoyao316 Did you call osn.NodeObs.OBS_service_startStreaming()?

If you get it working, it would be great if you could create a PR to https://github.com/hrueger/obs-studio-node-docs with instructions on how to setup streaming.