Question about developing multiple output or raw output pipe

forestj

New Member
Hello, I like to use OBS to "record" HLS video for live streaming using the custom ffmpeg output:


I have been doing research and I haven't found a way to configure this yet. I'm willing to do custom development to make it work I just don't know where to start.

I made a post about it at the bottom of this new feature ideas thread: https://ideas.obsproject.com/posts/41/multiple-video-outputs-selective-recording-iso-recording

Here are some ideas I had:

1. Use some internal OBS API functions that are not exposed in the user interface
OR
2. Write a plugin to create/expose more fine grained control over ffmpeg output
OR
3. Modify OBS to create/expose more fine grained control over ffmpeg output

Obviously #1 would be preferred. #2 would be ok, and I would really like to avoid #3

Once I figure out a strategy of how to expand whats possible for me to configure in OBS, there are a couple different goals I can work towards:

A. Come up with a way to customize the FFMPEG configuration / commandline so that it supports multiple outputs ala:
OR
B. Come up with a way to output the raw video stream (not encoded) from OBS to an external FFMPEG instance that I have more control over.
This would be like the "Lossless Quality, Tremendously Large File Size" option, but instead of recording to a file, it would go over RTMP or otherwise get piped into an external FFMPEG process.
 

forestj

New Member
Oops I accidentally posted my message before I finished writing it, and now I cannot edit the message any more. :(

here is a link to the complete edited message:


and here is the section I added:

------------------------

Hello, I like to use OBS to "record" HLS video for live streaming using the custom ffmpeg output:


https://obsproject.com/forum/resources/how-to-do-hls-streaming-in-obs-open-broadcast-studio.945/

This works really great for my use case, the only problem is I only get one HLS quality level, ideally I could configure multiple qualities to offer the best possible experience to my stream viewers. I'm well aware that usually the multiple quality levels are generated on the "streaming server" side after the video has been encoded by OBS & shipped to the streaming server over RTMP.


I'm particularly interested in self-hosted video streaming ala owncast and peertube. IMO, for those use cases, it would make much more sense to do ALL of the video encoding work on the streaming PC, in order to reduce the load / system requirements on the streaming server.

Here is a post I wrote about my progress so far: https://sequentialread.com/how-i-optimized-my-owncast-stream-to-run-on-a-raspberry-pi-part-2/

I have been doing research and I haven't found a way to configure this with multiple quality levels in OBS yet. I'm willing to do custom development to make it work I just don't know where to start.
 

forestj

New Member
Ok so I asked this question on the Discord server, here are the highlights of responses I got:


ChiyoToday at 12:00 PM
@Forest there are a few ways of going about this, and they all suck

option 1: use virtual camera
the bad: you lose chroma resolution, ffmpeg might suffer from buffer overflow
the good: it's relatively easy to set up

option 2: use ffmpeg's display capture or window capture to capture a projector, also use dshow + audio monitoring to capture audio
the bad: performance
the good: might also be easy to set up

option 3: output rawvideo or something lightly compressed to URL, then feed that URL to ffmpeg (if needed, i can link guides for UDP and RTMP outputs)
the bad: quality loss
the good: it's somewhat reliabl

piping raw video and audio from obs to ffmpeg is painfully difficult and i tried multiple times, never getting satisfactory results, it's either a ton of extra latency and quality loss, or major reliability issues, usually both

@Forest while i would very much like a way to pipe audio and video from obs-studio to ffmpeg, i have suspicion that the only reason such a thing doesn't exist yet is that it's too difficult for what it's worth

oh, you just want 2 independent outputs? that's relatively easy, no coding required, just switch recording output to ffmpeg output mode and use that for your second HLS stream, that should work, although you won't get much tech support for it

forestToday at 12:01 PM
OHH so you mean stream and record at the same time ?
:rollsafe:

thats actually a hilarious hack but it would work

??? how would you do that ?


ChiyoToday at 12:01 PM
yes, use the streaming output for your first hls stream, then the recording output in ffmpeg mode for your second hls stream, i haven't done this myself for hls, but other protocols (udp, rtmp) do work in ffmpeg output mode

-----------------------------------------------

Thank you Chiyo for the helpful ideas and detailed account of your own research into this!!

I think chiyo was imagining that I ultimately wanted two RTMP streams with different qualities or something, instead of wanting two sets of HLS segment files. So I tried to make some diagrams to explain my motivation:


1640718078303.png

1640718086249.png


Ultimately I think this is the best solution I can come up with without modifying OBS or creating a plugin:

1640718781668.png



I was also looking at the code to try to figure out where I would even start with the creation of a plugin to do this "properly"


forestToday at 11:58 AM
Well I was just looking in the code and it looks like the part where it configures the ffmpeg hls output is written in C. Basically I just want to modify that part to have 2 HLS stream outputs, 1 low quality and 2 higher quality

https://github.com/obsproject/obs-studio/blob/master/plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c
https://github.com/obsproject/obs-studio/blob/master/plugins/obs-ffmpeg/obs-ffmpeg-output.h
 

forestj

New Member
Actually, now that I think about it, I bet this OBS plugin would do exactly what I need!


That way I could have an unlimited # of quality levels and everything would always work the same way -- slightly less janky than both "recording" and "streaming" at the same time.

Very cool. I will update this thread if I ever get around to implementing it. :D
 
Top