Lowering filesize while maintaining high quality video

RecordingGoose

New Member
I made this account just to ask as this has been plaguing me for the past couple of months and im at my limit. What's wrong with this app?! I've looked at countless forums about this but everytime they always say "change this bro" and when i change that nothing happens!

Ok i need to calm down, my issue is that im lacking storage space and i want my files to have a nice quality (720p or 1080p) while maintaining a reasonable filesize. The problem comes when i try to change anything and end up with videos that look like abstract paintings while still being excessively heavy for no reason at all! Every single thread on this forum that talks about this always says to change certain settings without explaining them at all, and when i change those settings either nothing changes in the slightest or the problem gets worse.

Yes, i've already tried the auto configurator wizard. Yes, i've already put my settings in advanced and messed with the CQP stuff and that barely helps. All that ends up happening when i change my settings is that:
a- The video looks like complete garbage
b- The video weighs more than it should
c- Both of these things combined

Excuse me if i sound mad (its because i am), but ive tinkered with the app for long enough to where even opening the settings tab irritates me.

I don't even need an explanation as to what things do what (because i imagine understanding anything is just gonna make this worse), i just want a screenshot of what the "optimal" settings for this might be. Another forum had a settings screenshot but its from 4 years ago and the settings tab lacks the stuff that was shown.

Sorry/Thanks in advance. Any help would be appreciated.
 

koala

Active Member
That's a quite common issue people have. It's more a matter of understanding, not that much a matter of configuration.
There is always a balance between quality and file size. The more quality a video has, the bigger the file size. To maintain a certain file size, the encoder has to remove a certain amount of detail. The more detail it removes, the smaller the file size. But also the more detail it removes, the worse the quality.

How big a video becomes also depends on the type of footage. Some mostly still video, for example recordings of a Windows desktop with someone explaining something in Excel has extremely low volume, because almost all frames are the same. On the other hand a video with high movement such as with shooter games, additionally with foliage and high detailed graphics moving, will result in huge video files, because every frame is highly detailed and vastly different from the previous frame - this cannot be compressed well.

Now to encoder settings. There are 2 fundamentally different configuration types, or "rate controls". One rate control type is bitrate based. You tell the encoder you want a certain constant bitrate (or variable between a lower and a higher limit), and the encoder will remove as much detail until the resulting video is so small it matches that bitrate. CBR and VBR are such rate controls. You use these kind of rate controls for streaming, because it's necessary to maintain a constant bitrate for many reasons. This will result in videos of the same size no matter the raw video, just dependent on length. The size can be computed: size = bitrate * length. It will look awful for high detailed video, because the more detail the video has, the more detail must be removed to maintain the bitrate.
This rate control is just meant for streaming. Not for recording for archival and not for recoding+uploading to some video service.

The other rate control type is quality based. You tell the encoder you want a certain quality, and the encoder will remove the same amount of detail from every frame to maintain that quality. This will result in big videos for highly detailed/high motion video and small videos for low detailed/low motion video, because no matter the original quality, the same fraction of quality is removed for every frame. CQP is such a rate control. This kind of rate control is suited for video archival and if you intend to postprocess the video, because it guarantees the quality you define. You set the CQ value in the encoder configuration and every frame will match that given value.

There is another quality based rate control available for x264, CRF. This is similar to CQP with the difference that it will remove a little bit more detail for extremely high motion sequences. The idea is that the eye isn't able to perceive every detail with such scenes anyway, so there can be more detail removed, so the resulting video will be smaller. It's also a rate control suited for archival like CQP. But not that much if you intend to postprocess the video, because if you postprocess the high motion parts, quality will degrade even more.

So x264 with CRF will result in the best balance between file size and quality for archived video. However, that's only available with the software encoder, and if you directly encode video while capturing, you will overload your CPU. Not all x264 CRF settings will result in acceptable quality, the acceptable settings require quite some CPU resources which you might not have at the time of capturing.

My recommendation is a 2 step workflow. The first step is to capture your video with a hardware encoder in CQP mode with a high quality setting. You use this implicitly, if you use simple output mode of OBS with a hardware encoder and choose "indistinguishable quality". This will result in quite big files, with great quality you cannot usually distinguish between the original.

In a second step, recode your existing video with a tool like Handbrake or just with the ffmpeg command line tool. This step creates the final size and quality you want your archive be. This time you use x264 with the CRF rate control. Choose the CRF value so the resulting video matches your demands of quality and file size. Often you can use the same value for CRF as you did for CQP. The resulting video will be about half the file size of CQP with about the same perceived quality. Choosing the x264 preset is important, because this can vastly change quality as well: slow or veryslow is a proper preset for recoding archival footage.


About values:
indistinguishable quality for CQP is about 18. Depends a little bit on resolution, but 18 is a reasonably high quality setting. Higher values are lower quality. 30 is very low, 40 is blurry mess. Lower than 15 just increases file size for no visual difference. A change of +-3 about doubles/halves the file size.

Almost the same is true for CRF. Depending on your quality demand, you will probably choose the same values as you chose for CQP, or a little higher.

Keep in mind it makes no sense to first record with CQP with low quality then try to recode with CRF with high quality - you cannot regain quality previously removed. So tend to choose a slightly lower value for the CQP with the recording step, then a slightly higher value for the CRF archival step.

ps. I completely forgot about the other encoders: HEVC and AV1. These achieve about half the file size with the same quality as h.264, so they're a good alternative for archival. The part about bitrate and quality based rate control is the same with them. If you confirmed your media players and postprocessing tools support these encoders, you're free to use these instead of h.264. My recommendation to use a hardware encoder in the first step stays the same. May be you don't need the second step any more, but you could as well use HEVC/AV1 for the Handbrake step. Depends on what your media player supports.
 
Last edited:

Wivine Geek

New Member
Could you advise me?
I start with OBS.
I just want to make recordings (in front of my computer with little movement and with screen capture). I also have a fairly weak connection (I work via connection sharing from my iPhone).
When I record I don't get the entire recording, the video cuts off before the end. It's very annoying and I really want to get there.
thank you for your help. Could you give me the precise settings to choose please?
 

Lawrence_SoCal

Active Member
@koala - impressively patient and thorough response. kudos

@RecordingGoose
+1 to everything @koala said (he knows WAY more than I do regarding OBS Studio)

- the shorter version (I'm usually the one with the long-winded response) is that real-time video encoding is _really_ computationally demanding. Many modern devices (phones, tablets, etc) have dedicated hardware encoders to offload the work from the CPU. And this stuff gets complicated quickly. There really aren't 'easy' buttons, short of spending a LOT of money, and even then...

To @koala's PS - the way to compress a video more (smaller file size) without reducing quality is to use a different (more recent/effective) encoder [which then means a LOT more computational load]. AV1 can reduce file size, but... it depends... (ex. see EposVox comparison videos) there appears to be, with current hardware encoders and algorithms, a bigger difference at higher bitrates... for smaller files (bitrates) the differences aren't that significant (but, ymmv).
Your computer, using the OBS Studio auto-config wizard, is likely to be close to as good as you can get (presuming you have a hardware video encoders offload ability, and OBS Studio detects that... OS and driver issues can sometimes make that less than 'easy').
- so first thing is to make sure (don't assume) hardware video encode offload (assuming you have such) is working
Beyond OBS Studio auto-config, there is bound to be some optimization opportunities, but would get technical quickly, and you ignored the pinned post in this forum about posting OBS Studio log when asking for help/support, so... maybe a step too far ?? Sorry, I'm not aware of a good alternative other than understanding and following detailed technical instructions, being patient & detailed in testing, etc.

then you have a choice:
- the mentioned multi-step process, with a later re-encoding (most likely not real-time) to optimize size and quality... but this means having sufficient working disk space
- spend money on hardware upgrade to get a newer/better video encode offload ability (ex AV1)
or
- upgrade storage space and (largely) ignore file size

So, for a laptop, your basically stuck (extremely rare to be able to to upgrade discrete GPU on a laptop) and if you want new GPU that means whole new laptop. A GPU upgrade in a desktop is common, but again, depends on details/specifics. And will cost more (probably a fair amount more) than upgrading your storage device to something with a lot larger capacity (relatively easy in most laptops and desktops)
so if your whole request is due to lack of disk space... most likely your most cost-effective solution is to increase your storage space. the only typical obstacle is cost (which will be less than GPU or new computer) or the rare systems with soldered (non-upgradeable) disk storage [I hate those devices... and I have 1... given to me.. anyways]
 
Last edited:

Lawrence_SoCal

Active Member
regarding disk space
- if you have an SSD, and its almost full, and you run your system that way month-in, month out, then beware - you are basically ruining the drive (limited write cycles spread across limited # of cells)
modern drives are better than the original SATA SSDs, but basic physics dictates same issue is at play, vendors simply have adjusted firmware, over-provisioned, and a few more things to push out SSD drive failures beyond warranty period [when run running for extended period at/near full].
- I have my main OS drive, and record there. But then I promptly move my video recordings to an archive HDD

As for Recording settings:
- sorry, but it really does depend, and there is not single 'right'/'best' answer. It depends on the specific content, OS background processes, physical hardware resource utilization, etc. ... all of which varies, and is specific to person, system, and current s/w running (ie potentially changes with every monthly OS patch, driver and app update, etc)... yes, when trying to truly optimize, it is that complicated.
And if running at max, any small thing can push system to overload and you'll have to start Recording over [and to avoid further frustration, would require sufficient system monitoring to identify EXACTLY what changed/was different to avoid simply repeating failure... and very few people do this].

Good luck
 
Top