Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th March 2022, 11:22   #1  |  Link
Dave_Scream
Registered User
 
Join Date: Apr 2014
Posts: 3
Best x265 quality/filesize settings (reencode for archive)

I have DJI Pocket2 camera. Recordings from 1080p@30fps to 2160@60fps. Bitrate from camera is ~80 mb/s. I need to compress this with maximum quality to file size ratio (limited NAS storage).

Encoding speed is not so important for me because I use queue and Xeon E5 2696v3 (Haswell 18 cores 36 threads) is doing well too.

I tryed to use SVT-HEVC and SVT-AV1 but they are blurry and dont have CRF mode (only CQP mode which i think is not best for visual quality/filesize purposes).

As for now I use x265 veryslow + opus 96kbps with original resolution (1080-2160) and frame rate (30-60).

crf 28 - for not important videos (like unboxing, or conversations with people)
crf 24 - for more quality videos (like sea or nature or zoo).

on my 32'' monitor 2k resolution I cant see any differences, so need help

What settings I should I use for best visual quality/filesize ratio source files from my dji camerф are:

ideo
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference fra : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 2 min 50 s
Bit rate mode : Variable
Bit rate : 50.0 Mb/s
Width : 2 720 pixels
Height : 1 530 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 (30000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.401
Stream size : 1 017 MiB (100%)
Title : DJI.AVC
Language : English
Encoded date : UTC 2022-03-03 16:01:15
Tagged date : UTC 2022-03-03 16:01:15
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Codec configuration box : avcC

Should I use 10 bit if video from DJI is 8bit yuv 4:2:0?

I tryed to use aq-mode 3 instead of 1 (default) but bitrate insanely grows. So what is better:
aq-mode 1 crf 24 8bit (94mbyte)
or
aq-mode 3 crf 30 10bit (97mbyte)?

Should I somehow tune veryslow preset? (set more than 3 ref frames and 4 b-frames)?





Maybe aom-av1? But 0.5 fps speed is very slow even for me(((

Last edited by Dave_Scream; 7th March 2022 at 11:34.
Dave_Scream is offline   Reply With Quote
Old 7th March 2022, 14:15   #2  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
personally I would:
a. use way lower crf values (around 12) for important stuff and probably not go below 22 for anything that I want to keep.
b. make sure look at the content in native resolution before deciding on crf (most players should allow to also display content unresized).
c. use preset slow.
d. look into filtering. Often some light denoising/degain can same tons of data rate, if using Avisynth/Vapoursynth isn't an option even using the noise reduction options of x265 might be worth using
e. regarding aq-mode, prefer mode 3 over 1.

Regarding av1, I would recommend reading https://forum.doom9.org/showthread.php?t=183907 and using aomenc.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 7th March 2022, 16:13   #3  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 328
I agree with Selur that your CRF values are way too high, but your encode speed profile at very slow, is fine.
RanmaCanada is offline   Reply With Quote
Old 7th March 2022, 16:17   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Quote:
but your encode speed profile at very slow, is fine.
Where did you get that from in his post? (I just read that aom-av1 was to slow for him.)
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 7th March 2022, 18:11   #5  |  Link
Dave_Scream
Registered User
 
Join Date: Apr 2014
Posts: 3
Quote:
Originally Posted by Selur View Post
Where did you get that from in his post? (I just read that aom-av1 was to slow for him.)
Thank you Selur) After all choices, I finished using Hybrid. Only one problem with saving timestamps of original file (under windows). Not able to save this in new filenames. This information is lost.


Im using veryslow preset (got 2.3fps):
Quote:
As for now I use x265 veryslow + opus 96kbps with original resolution (1080-2160) and frame rate (30-60).
Use "x265 Hybrid Default" but set Bit depth 8-bit and Preset veryslow and aq-mode 3 gives me this cmd line:

Code:
x265 --input - --output-depth 8 --y4m --profile main10 --limit-modes --no-early-skip --rskip 0 --no-open-gop --opt-ref-list-length-pps --lookahead-slices 0 --crf 18.00 --opt-qp-pps --cbqpoffs -2 --crqpoffs -2 --qpfile GENERATED_QP_FILE --limit-refs 0 --ssim-rd --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 10.00 --aq-mode 3 --no-cutree --deblock=-1:-1 --limit-sao --no-repeat-headers --range limited --colormatrix unknown --output "C:\temp\DJI_0837_x265_crf18_veryslow_aq3_opus96.265"
With this settings I get 104Mbps it even bigger than my source bitrate from DJI Pocket2 (60-100mbps).

For my 4TB Nas storage acceptable bitrate for video archive is around 8-15mbit/s and want to find optimal settings for this.

I just want to use power and unlimited time of my PC to increase compress ratio for my DJI camera and mobile phone videos. Because I have limited storage.

Another question is that I think no need to resize video to 1080p (lost information). Better to use original resolution and frame rate and use acceptable CRF for my acceptable bitrate.

Last edited by Dave_Scream; 7th March 2022 at 18:16.
Dave_Scream is offline   Reply With Quote
Old 7th March 2022, 18:14   #6  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 328
Quote:
Originally Posted by Selur View Post
Where did you get that from in his post? (I just read that aom-av1 was to slow for him.)
As for now I use x265 veryslow + opus 96kbps with original resolution (1080-2160) and frame rate (30-60).


We know that AV1 is a mess with it not implementing switches and some versions being single threaded, etc. Veryslow on x265 will still be faster than AV1 if AV1 is being dumb, which it has been every time I've tried to use it haha.
RanmaCanada is offline   Reply With Quote
Old 7th March 2022, 18:19   #7  |  Link
Dave_Scream
Registered User
 
Join Date: Apr 2014
Posts: 3
Quote:
Originally Posted by RanmaCanada View Post
As for now I use x265 veryslow + opus 96kbps with original resolution (1080-2160) and frame rate (30-60).


We know that AV1 is a mess with it not implementing switches and some versions being single threaded, etc. Veryslow on x265 will still be faster than AV1 if AV1 is being dumb, which it has been every time I've tried to use it haha.
Yeah av1 is very slow. alternative to x265 could be SVT-AV1 (for my Xeon SVT optimizations are good). But it is blurry and dont have CRF as I understand (((

Selur as author of so powerful Hybrid, what free codec you think is optimal for now to use for encodings in terms of quality to size ratio (and not deadly slow as 0.5 fps on 18 cores CPU)?
Dave_Scream is offline   Reply With Quote
Old 7th March 2022, 18:38   #8  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Quote:
Selur as author of so powerful Hybrid, what free codec you think is optimal for now to use for encodings?
Hmmm,... since I'm not sure what you call a 'free codec' I restrict it to the encoder Hybrid supports and that are free to use.

Since you aim for "best visual quality/filesize ratio" while you want a lower file size any lossless are near lossless formats are not interessting.
So the choice is either H.264, H.265 or AV-1.
So looking at the encoders for those formats:
For H.264: x264 is the only choice that makes sense.
For H.265: x265 or gpu based encoding can make sense, but since it's for archiving while minimizing file size I would definitly go for x265.
For AV1: I would go for aomenc, it's way slower than rav1e and stv-av1, but it simply beats them in quality.
Personally I like aomenc and the resulty you can get if you tweak the settings, but atm. I wouldn't recommend it for archival of content that I want to edit, since I'm not sure how hardware decoding support and support in NLEs is looking at the near future. Paired with that its really rather slow I wouldn't recommend it atm. for archiving. I see that AV1 will probably stay as a format used for streaming, but likely not for broadcasting which probably will restrict the speed of hardware decoding support for it. (especially if it's not 4:2:0 content) I would probably be more leaned towards av1 if aomenc was faster.
VVC also seems interessting, but atm. it's not really main stream user friendly and really slow.

Since you are aiming for HD and higher resolutions I would recommend H.265 over H.264 since in my book it clearly wins over H.264 when it comes to HD+ resolutions also it's general supported profile had 10bit in it which helps with banding.
-> At the current time I would recommend x265 and looking into filtering (light deblocking, denoising/degrain are usually a must in my book if reducing the bit rate is a goal).
Important: When encoding non-anime/cartoon content especially make sure not to overfilter when aiming to archive content.

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 7th March 2022 at 18:41.
Selur is offline   Reply With Quote
Old 7th March 2022, 19:00   #9  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
In general, it's really hard to make comparisons >1080p on a 1080p monitor. Your best bet is to use a player that can zoom in to a center cut at 1:1 pixels and examine those.

If you've not done visual quality comparisons, those detailed command line parameters are all really premature, and why your bitrate is so high.

I'd start with something simple like this.
Code:
--preset slower --profile main --level-idc 5.0 --crf 21
Then iterate if/as needed based on quality, encoding time, and bitrate.

Going through your command line parameters:
Code:
--output-depth 8 --y4m --profile main10
I'd use main if only encoding 8-bit. That'll speed up encoding a fair amount.
Code:
--no-open-gop
Any reason not to use Open GOP? That's generally better unless you're doing adaptive streaming.

Code:
--limit-modes --no-early-skip --limit-refs 0
These kinds of options are generally best set via a --preset, as those have good clusters of speed/quality tradeoff

Code:
--rskip 0
--rskip 2 can provide similar results quite a bit faster. You can lower --rskip-edge-threshold to 3 if you have noisier sources.

Code:
--opt-ref-list-length-pps --opt-qp-pps
These won't do anything useful at these bitrates.

Code:
--lookahead-slices 0
Lookahead slices are generally very safe to use and can improve performance. The frame threading option that can improve quality by lowering is --frame-threads. Although the quality gain is a lot less in modern x265 versions.

Code:
--cbqpoffs -2 --crqpoffs -2
These are likely to be a net negative for Rec. 709, as the bits taken from luma will hurt quality more than the bits added to chroma will help.

Code:
--ssim-rd
That is an experimental feature that never panned out as something appropriate to use by default, as a lot of other assumptions and constants in x265 assumed SAD. It's also quite a bit slower. Even if it worked well, it would only matter at much lower bitrates. I'd probably only use it with --tune ssim if I was trying to win a SSIM metrics comparison, but not to make something look better.

Code:
--psy-rd 2.50 --rdoq-level 2 --psy-rdoq 10.00
Is this particularly grainy/noisy content? Those can help improve detail retention, at the cost of increased bitrate. I wouldn't use values that high by default.

Code:
--aq-mode 3
This can also increase bitrate a lot, essentially by lowering CRF even more for dark regions. It can help 8-bit SDR quality in dark areas, but that might not be needed at --crf 18. The main use of --aq-mode 3 is to allow for a higher CRF when quality in dark regions is the only reason to use a lower one.

Code:
--no-cutree
This could well be a net negative in terms of quality @ bitrate unless you've got unusual amounts of noise.

Code:
--deblock=-1:-1
That's generally a x264 thing. Do you have any particular reason to think it would be helpful here?

Code:
--limit-sao
If you're worried about detail preservation, you should be using --no-sao! That'll have a bigger impact than other stuff you're doing.
If you still want to use SAO for some reason, you can also use --selective-sao 2 to increase encoding speed a bit.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 7th March 2022, 22:57   #10  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by benwaggoner View Post
I'd start with something simple like this.
Code:
--preset slower --profile main --level-idc 5.0 --crf 21
Just a note here, although I also recommend specifying the level, level 5 doesnt support 2160p60 (which was mentioned in the first post).
Quote:
I'd use main if only encoding 8-bit. That'll speed up encoding a fair amount.
It seems like Dave is mostly interested in tuning for compression, trying main10 is definitely something that might be worth pursuing even though it has a bit of an speed impact.
Quote:
If you're worried about detail preservation, you should be using --no-sao! That'll have a bigger impact than other stuff you're doing.
If you still want to use SAO for some reason, you can also use --selective-sao 2 to increase encoding speed a bit.
SAO has such a negatable speed impact that it is imo almost an irrelevant factor.

Quote:
Originally Posted by Dave_Scream View Post
I tryed to use aq-mode 3 instead of 1 (default) but bitrate insanely grows. So what is better:
aq-mode 1 crf 24 8bit (94mbyte)
or
aq-mode 3 crf 30 10bit (97mbyte)?
Whatever you think looks the best... Its normal that different aq-modes changes the bitrate at a given crf value.
Quote:
Should I somehow tune veryslow preset? (set more than 3 ref frames and 4 b-frames)?
lower presets will increase the number of ref frames and b-frames by default. At such low presets I would probably leave it to the encoder to set those to ensure playback compatibility.

My 2 cents is to start with preset 'slower' (but hey if you find 'veryslow' usable go ahead, but you are in the relm of diminishing returns) and try to find out an combination of aq-mode, sao & crf value that you are happy with. In my experience when using under crf 20(ish) aq-mode 1 and no-sao is preferred in most cases, when going for a lot of compression (crf20-30) feel free to play with aq-mode 3 or 4, and sao/selective-sao. I also assume that compression is more important than seeking etc, so you can also set --keyint fps*10 --min-keyint fps. Using main10 is also something that you might wanna try as well (I personally only use main10 with x265, regardless of if the source is 8bit or not). As for all the other tuning that can be done... I'm gonna stay out of that, as it can be a rabit hole of pros & cons and can be dependent on a myriad of factors.
excellentswordfight is offline   Reply With Quote
Old 8th March 2022, 06:56   #11  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Definitely --main10 and --no-sao. --preset slower --crf 16 --aq-mode 1 --rskip 2 --rskip-edge-threshold 2 will already give a nice basis for everything else, CRF 18 for the less important content. --ctu 32 on top of that in my opinion, I've found out that CTU 64 sometimes causes issues with flat backgrounds.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th March 2022, 17:24   #12  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
Originally Posted by excellentswordfight View Post
Just a note here, although I also recommend specifying the level, level 5 doesnt support 2160p60 (which was mentioned in the first post).
Oops! Yeah, --level-idc 5.1 instead.

Quote:
It seems like Dave is mostly interested in tuning for compression, trying main10 is definitely something that might be worth pursuing even though it has a bit of an speed impact.
Main10 doesn't give much benefit at all over Main for 8-bit input and output in HEVC. It had a much bigger benefit in H.264.

Quote:
SAO has such a negatable speed impact that it is imo almost an irrelevant factor.
Yeah, quality is main reason for SAO on/off. At high bitrates, SAO can impair maximum detail. But at lower bitrates, SAO can suppress ringing and net improve visual quality.

Quote:
Whatever you think looks the best... Its normal that different aq-modes changes the bitrate at a given crf value.
A good reminder that it is often preferable to do psychovisual parameter tuning in 2-pass VBR mode, so one is comparing quality at a given average bitrate. Otherwise one winds up comparing different visual quality at different file sizes, which can be confounding.

Quote:
I also assume that compression is more important than seeking etc, so you can also set --keyint fps*10 --min-keyint fps. Using main10 is also something that you might wanna try as well (I personally only use main10 with x265, regardless of if the source is 8bit or not). As for all the other tuning that can be done... I'm gonna stay out of that, as it can be a rabit hole of pros & cons and can be dependent on a myriad of factors.
At 60 fps, that'd be a --keyint 600, which can make random access really slow. Compression efficiency is much more about the value of keyint itself (proxy for percentage of IDR frames). I'd probably start with --keyint 300 myself, for a maximum of a 5 second GOP
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 8th March 2022, 22:39   #13  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by benwaggoner View Post
Main10 doesn't give much benefit at all over Main for 8-bit input and output in HEVC. It had a much bigger benefit in H.264.
We touched on this subject before, clearly, this isn't necessarily generally true for x265.

Last edited by excellentswordfight; 8th March 2022 at 22:50.
excellentswordfight is offline   Reply With Quote
Old 9th March 2022, 18:05   #14  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
Originally Posted by excellentswordfight View Post
We touched on this subject before, clearly, this isn't necessarily generally true for x265.
Oh, right! Thanks for the reminder.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.