question about optimal settings

Discuss encoding for devices and presets.
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

question about optimal settings

Post by happyencoder_ »

Hello, i am using handbrake to encode my vids for personal backup. Mostly it's webcam videos. Right now i am using x265 software encoding, 25RF, constant-original fps, fast preset, original resolution but i limit it at 720p. For audio i usualy use AAC 16Khz and 40kbps to keep the size as small as possible. Generaly i encode from AVC .mp4 files. I dont use any additional options or settings so apart from stated above, everything is at default.

1) I was wondering, are there any better settings or additional command line arguments i could add to further save on size of file, quality or encoding time ? I know there are special guides for animes that improve quality/size/speed. Not sure is anything like this exists for camshows.

2) One area where i was sure i would save on size was fps. I thought it was a waste to record at constant 30fps since a lot of the time, image is almost completely stationary for much of the time (person sitting and looking into camera). So i set it at variable 30fps so that encoder could just use less frames in areas where picture doesn't change at all for half a second or more. This should in theory save a lot on file size but to my surprise, constant vs variable fps almost produces file of almost identical size. So i was wondering, am i understanding the variable fps the wrong way ? I know people prefer constant fps to avoid video/audio desync, but i check every file and so far i didnt get desync yet.
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

Re: question about optimal settings

Post by happyencoder_ »

Anyone ?
mduell
Veteran User
Posts: 8182
Joined: Sat Apr 21, 2007 8:54 pm

Re: question about optimal settings

Post by mduell »

1) Yes. Pick two of quality/size/speed and there are generally tradeoffs you can make.

2) You're not wrong, you're just a few decades late; contemporary video encoders take extensive advantage of the fact that much of the picture doesn't move, or moves together. So decimating/having/etc frames doesn't really make much of a difference in size, since it took very few bits to say "this block looks just like the prior frame in the same/nearby place." See https://en.wikipedia.org/wiki/Inter_frame
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

Re: question about optimal settings

Post by happyencoder_ »

Thank you. How about video dimension vs RF vs encoder setting (fast, medium, normal, etc.). If i want as good quality as possible vs file size, which should i lower first ? For instance, keep 720p and higher RF or lower resolution and keep low RF, or just use very fast instead of fast ? If there is any good comparison in a guide, i can read it myself
mduell
Veteran User
Posts: 8182
Joined: Sat Apr 21, 2007 8:54 pm

Re: question about optimal settings

Post by mduell »

Start with the source resolution. Try the encoder settings to find the slowest one you can tolerate. Then try the quality scale to find the highest RF you can tolerate. If that RF is below 30ish, that's probably best for your personal preferences.

If that RF is above 30 or so, try a quarter of the resolution, repeat the encoder setting testing, and repeat the quality testing.
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

Re: question about optimal settings

Post by happyencoder_ »

Tnx. Im usualy in the 25-30RF range where 25RF is for vids where i want high quality and up to 30RF for vids where i just want backup of vid. Right now i use fast preset in handbrake. The thing is ... the faster the preset - the slower the file (and faster encoding), the slower the preset, the bigger file size, better quality and slower encoding. So its kind of hard to pick quality and size and trade it for time - longer time means better quality but also bigger file, at least its like that for me.

I have a lot of videos that are all 30fps, but you can clearly see that the actual video camera was recording at like 10 or15 fps, but the capture was done at 30 fps. This in effect means that i am wasting half frames since if video camera was recording at 15 fps, there is no point in storing the vid with more than 30 fps. I was wondering, is there any program or something that could, maybe using AI, figure out what the real video fps really is ? I mean, of the top of my head, something similar could be done to go through the video and see "per how many frames" the image actualy changes. For instance if the image only changes every 3 frames and video is stored with 30 fps, you could actualy just use 10fps constant framerate and be alright. Now, maybe it doesn't affect the file size that much because as you already pointed, x265 is good at sensing such things and optimising information storage. But i did some testing and 30 vs 25 vs 20 fps does give me smaller file size, not much but considering i have lots of data, it could be summed to a considerable amount of space saved
Deleted User 11865

Re: question about optimal settings

Post by Deleted User 11865 »

It doesn't matter-- duplicate identical frames are very easy to compress, you'd be saving maybe 1% file size by actually dropping those duplicates instead of just letting the encoder handle them.
mduell
Veteran User
Posts: 8182
Joined: Sat Apr 21, 2007 8:54 pm

Re: question about optimal settings

Post by mduell »

happyencoder_ wrote: Sat Jun 10, 2023 11:06 pmTnx. Im usualy in the 25-30RF range where 25RF is for vids where i want high quality and up to 30RF for vids where i just want backup of vid. Right now i use fast preset in handbrake. The thing is ... the faster the preset - the slower the file (and faster encoding), the slower the preset, the bigger file size, better quality and slower encoding. So its kind of hard to pick quality and size and trade it for time - longer time means better quality but also bigger file, at least its like that for me.
The RF scale is constant quality across videos with the same encoder settings, not constant quality across different encoding settings. RF 25 at veryslow isn't the same output as RF 25 at veryfast. The slower x264 presets are always giving you more actual quality for size. This is why I recommended the process I did, finding your tolerable encoding speed before finding your preferred RF.
happyencoder_ wrote: Sat Jun 10, 2023 11:06 pmI have a lot of videos that are all 30fps, but you can clearly see that the actual video camera was recording at like 10 or15 fps, but the capture was done at 30 fps. This in effect means that i am wasting half frames since if video camera was recording at 15 fps, there is no point in storing the vid with more than 30 fps. I was wondering, is there any program or something that could, maybe using AI, figure out what the real video fps really is ? I mean, of the top of my head, something similar could be done to go through the video and see "per how many frames" the image actualy changes. For instance if the image only changes every 3 frames and video is stored with 30 fps, you could actualy just use 10fps constant framerate and be alright. Now, maybe it doesn't affect the file size that much because as you already pointed, x265 is good at sensing such things and optimising information storage. But i did some testing and 30 vs 25 vs 20 fps does give me smaller file size, not much but considering i have lots of data, it could be summed to a considerable amount of space saved
This won't really save anything due to inter frame encoding (for the last several decades) making the unchanged frames take an incredibly small number of bytes.

https://en.wikipedia.org/wiki/Inter_frame
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

Re: question about optimal settings

Post by happyencoder_ »

Tnx. I have another question.

Let's say i use "keep original resolution", fast preset and RF25. I use this settings on 2 different videos. First video is good quality 720p recording, picture of the original video is crisp. The second one is old 480p recording from 15 years ago and its all grainy, bad light, its bad quality recording. Does it make sense in keeping RF25 for both of those files ? I am wondering how RF actualy works, because in my head, if RF25 is a set quality ... and encoder will try to preserve this level of quality in first video, thats fine. But in second video, even the original video is, compared to first video like quality RF40. Do you see what i am saying ? So is using RF25 on this bad quality recording even worth it since i want as small size as possible ? Is it possible i would get the same quality at RF25 or RF35 since the bottleneck isnt the actual encoder setting but infact the original file ?

Would in this case it make more sense to simply look at this original file's average bitrate and knowing that its x264 encoded, then just instead of RF value, use average bitrate (constant bitrate instead of constant quality) ? This way, knowing that x265 is up to 50% more efficient than x264, lets say original bitrate is 200kbps, we could just set the new bitrate in the range of 100-150kbps and hope that this will give us decent quality at 25-50% less size ? Because i have problem with certain files, like some files i get a huge reduction in size after encoding, ranging from 50% to 500% in some cases. But with some files my encoded file is actualy larger than the original and keep in mind i use RF25 for all files. In that case i could change RF to 30, or ... just set the constant bitrate
mduell
Veteran User
Posts: 8182
Joined: Sat Apr 21, 2007 8:54 pm

Re: question about optimal settings

Post by mduell »

The quality scale is all about replicating what exists in the source video. The video encoder doesn't know what your crap 480p video is supposed to look like; the video encoder is trying to replicate what the crap 480p video does look like. This is why bad quality videos generally aren't worth re-encoding.

Knowing the encoder and the bitrate doesn't tell you a whole lot about what the video needs, only part of the story about how it got there; there's still a lot of variance between an ultrafast encode and a placebo encode. You can halve the bitrate with H.265 and sometimes you'll end up with a usable result and sometimes you'll end up with a crap result, because the bitrate doesn't tell the whole story.

Well-executed video encoding requires thought and observation, not blindly following a particular number or ratio.
rollin_eng
Veteran User
Posts: 4836
Joined: Wed May 04, 2011 11:06 pm

Re: question about optimal settings

Post by rollin_eng »

No single group of settings is going to be perfect for every source.

This is where it might be a good idea to create multiple presets for your different sources.
happyencoder_
Posts: 6
Joined: Thu Jun 01, 2023 8:23 pm

Re: question about optimal settings

Post by happyencoder_ »

Tnx. I understand that every video is its own story, i am in the process of making multiple presets to cover a wide variety of cases.

Just to clarify about my previous question about RF and 480p poor quality video vs good quality 720p. Using RF25 in good quality 720p videos, i get satisfactory result. And i can clearly see difference between RF25 vs RF25. For 480p poor quality videos would it make sense to see if i even get any better quality using RF25 vs RF30, considering that the source video in itself is probably RF40 or something and using lower RF will just increase size but not the actual quality (because as you said, encoder cannot give better quality than the source file)
rollin_eng
Veteran User
Posts: 4836
Joined: Wed May 04, 2011 11:06 pm

Re: question about optimal settings

Post by rollin_eng »

With these types of things it’s really up to you to try different settings and see what works for you and your setup.

If you go from RF30 to RF25 you will get a larger file and better quality, whether that is worth it for you is really only something you can judge.
Post Reply