Skip to content

Instantly share code, notes, and snippets.

@Decoherent
Last active January 6, 2025 23:23
Show Gist options
  • Save Decoherent/eb69f6844b7e35ef0fb31ea8bccaf1f0 to your computer and use it in GitHub Desktop.
Save Decoherent/eb69f6844b7e35ef0fb31ea8bccaf1f0 to your computer and use it in GitHub Desktop.
Video Lecture

[there is a longer tl;dr at the bottom]

The short, SHORT answer is OBS, for everything :)


OBS

I'm surprised he was streaming with something else. It can be a wicked complicated bit of software, but the defaults are all sane, and it's very user-friendly when you decide that you actually want to record B-frames ever 2 instead of 4 seconds, or whatever else weird corner you end up being very concerned over :) Streaming & recording at the same time is basically what inspired the program in the first place, hence the name.

Frankly, I wouldn't touch anything else, because I don't know what it's doing under the hood. Even if I don't change anything, it's important to know what it's doing, and how. For example, I bet whatever software he was using violated the single most important rule of capturing: never record to mp4! Ever! Unless there's a custom bit of hardware in the mix that you cannot change, in which case get a better piece of hardware :) The problem is, as our aspiring streamer has discovered, is that the mp4 container records all of its data necessary to use the video at the end of the file; if anything bad happens, like something crashing, you lose the entire file. OBS will let you do it, but it'll complain bitterly that you are making a terrible mistake :) Always record to Matroska, because the mkv container was devised with resilience in mind, and a crash will generally just eat the last couple minutes.

Lecture

I'm going to be insulting and video-splain the container thing, so I apologize if this is basic stuff :) mp4 and mkv are literally container formats, that contain carious streams of audio, video, metadata, subtitles, chapters, and so on. Both are actually codec-agnostic, more or less; most mp4 files contain either h264 or h265 and generally one of the Dolby audio codecs, but there's other codecs you can use. I can't be bothered to go look, but mp4 is MPEG part 14, IIRC, if someone is bored and wants to go look :)

One of the key differences (besides eating your entire 2 hour recording) is that the mp4 container can only contain a limited number of streams; 1 video and I think 2-3 audio. The Matroska container (such a fun word to say), on the other hand, will let you package up basically any damn thing you feel like, however many you want. 4 video streams? Sure. 18 different language audio files. Why not? These days one generally sees x264/AAC, or VP9/Opus if you're going free, or AV-1 if you have a really expensive computer that you want to set on fire, and not be able to play it on anything. Oh, and commercial NLE's (Premiere especially) are bitchy and won't even look at mkv files. OBS has a built-in remuxer, so at the end, it's trivial to just make a copy in mp4.

Our streamer should also be sure they're using the hardware NVENC encoder to encode. Hardware encoders used to be garbage, but by the 2xxx series of nVidia cards, it was pretty decent, and the 3xxx series is just good. Both benefit from having lots of bits thrown at them, if your storage is fast enough (at least a SATA SSD, NVMe recommended). I record with a "bitrate" using CQP (constant quality1) of 16, which is just a silly amount of data. I've seen it cheerfully spike to 100 Mb/s if it feels like it, but it's usually around 25 Mb/s. (1"CPQ" is actually 'constant quantizer parameter', that essentially means "constant quality"). My philosophy is that you can always drop bits, but not make them (interesting things like DLSS and FSR aside). For reference, I generally encode Blu-Rays with a CQP of 21. Note: the hardware encoder is on a different part of the silicon, and so gaming & recording have no effect on each other.


Other Software

When it comes to editing, if they wish to do so, things get a little more complicated. There aren't many NLE (non-linear editor) programs available that don't require losing a kidney: Vegas is $500, DaVinci Resolve Studio is $300 (?), After Effects CC is $600 or monthly, Premiere is subscription-only. Up front, let me just say: do not pirate Adobe Premiere, or any of these, really. They've been cloud-y for a while, and you'll get a fine selection of malware in your download. Vegas & After Effects are expensive enough that they take piracy very seriously (I'm not familiar with DaVinci). Kdenlive is an open-source NLE that I used to use before moving to Premiere. I see it's gotten a lot more capable since I used it. That's where I'd start, I think.

Audio-wise, your choice is Audacity. There are no other choices in my list :) I keep meaning to poke at Audition, since I have a license to all of Adobe's stuff, but I've never gotten around to it. Audacity is generally between "fine" and "great", with some caveats. The big one is, I use v3.5.1(standalone, installer), because that was before some company bought it, and stuffed it full of "encouragement" to buy their extra thing. Also, v3.6 changed how some of the tools work, and I don't like what they do. The audio guy I know and I poked at it for a couple hours and couldn't get it to work the way I wanted.

The other caveat is that for a "multi-stream" editor, it sure chokes after ~3+ streams or so :) It does depend on the size of the files, but if I'm making some clever bit or whatever, generally I just copy the track to a new instance, and copy back when I'm done. It never even brings my (getting older) desktop up from idle, so I have no idea what it's doing. The general work flow (for me) is, (a) import (ffmpeg will import anything), (b) merge the mic channel to mono, because for some reason OBS records my mic in stereo, which it isn't, (c) normalize (which brings the max peak up to 0 dB and balances), (d) run it through the audio compressor at about a 5:1 for or 3:1 for audio, which evens out the volume spikes and valleys, (e) amplify up to -1 dB (so there's some headroom if I need it), and (f) export it as a 32-bit float WAV, because I want lossless codecs until the final render.


Streaming

OK, OK, this is all fine and good, but who cares, I'm streaming! Well, my friend, you are in for a pleasant surprise, because OBS can do much of this in real-time, while streaming & recording. The two audio channels (mic & game) can each have real-time filters filters applied. They're at a disadvantage because they can't look ahead, but they are very good. They work in a chain, in order. Personally, I've used gain-> compressor-> gain again, either in the compressor itself, or another gain filter, which is easier to control by itself, IMHO. THe noise suppression is pretty solid, and nVidia has a codec that you can download that is hardware-based and has lots of dials. I'm not really familiar with the others. You can mess with the video, watermarks, overlays, and whatever else annoying things people put in their streams!

Anyway, like I said, these work in real-time, and the audio ones are sort of mandatory if you want to sound reasonable. Spent some quality time testing things, because every setup is going to be different. In OBS, you can set the recording settings to the streaming settings, which might be helpful for testing (don't leave it that way). Or, what's probably best, was my technique: have a kid, wait ~15 years to make sure they have a good ear, and start up a private stream with them in the next room to help tune. Sure, it's time-consuming and expensive up front, but it's very effective.

They can find tons of information about streaming via OBS on the internet, as it's a very common use. Generally, it's a fixed-bitrate, and by god you'd better have hardware encoders, or a second computer to do all the encoding work (surprisingly common, but not recommended). OBS has a couple very useful displays: audio meters for the two channels, so you can get yourself into the happy-green volume band, and a panel showing if you're having dropped/delayed frames, and why.

If you see the frames getting dropped due to either rendering or encoding lag, you can adjust things down until you have a nice 0% (or maybe a couple percent is fine, I don't watch any streamers, so I have no idea how much the eye can ignore). There's a display for CPU/Memory usage, and probably most importantly, dropped frames due to the network. I assume that means that you're trying to push too much data upstream, so you can turn the dial down. All of these stats are listed separately, so you're not trying to guess what your streaming problem is. Or, you know, get 500/500 fiber, where once your promo pricing ends, they drop the monthly price by a few dollars.

There are fractal numbers of details, and I never know if I'm getting too into the weeds for someone that doesn't care. I know entirely too much about how individual frames are encoded in several codecs, or more interestingly, how they're not (sort of delta frames between a full frame every second or two), quant parameters and what they do, but thankfully less about audio (although there's some interesting psychoacoustic work being done, where you use most of your bits in the frequencies human are sensitive to).


tl;dr

Finally.

  1. Use OBS for both recording and steaming.
  2. Add & mess with some audio filters on the mic channel, because you have to at least do some volume compression. YouTube and Twitch have recommended stream settings, so set your streaming output to those. (archive.org, because I don't understand their current page)
  3. If you're recording as well (and I don't make sense), OBS has sane defaults, a good wiki, and a friendly forum. Use the mkv video container, which OBS will push hard.
  4. Use hardware video encoding, full stop.
  5. Push the button.
  6. Push another button, because "Start Streaming" and "Start Recording" are separate :)
  7. Talk.
  8. ?
  9. Win.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment