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. |
27th July 2022, 16:22 | #8562 | Link | ||
Registered User
Join Date: Apr 2022
Posts: 28
|
Quote:
Quote:
For what it's worth, I've found on some machines that VS builds of x265.exe (and x264, aom-enc, SVT-AV1, to name a few) perform a bit better in some cases, but only negligibly. It does seemingly add up on Intel CPUs without AVX2 though, and it also allows you to use VS profiler guided optimizations (PGO) if you choose to, and in my case, disable things like Spectre slowdow...I mean mitigations, but only because I don't know how to pass that through to GCC. I can confirm Boulder's edit worked for compiling under VS2019. I add -A x64 out of habit, so cmake -G "Visual Studio 16 2019" -A x64 ..\..\source && cmake-gui ..\..\source. You would presumably edit it to read "Visual Studio 17 2022" if you're using 2022. Make sure you start a "x64 Native Tools Command Prompt for VS 2019" to run things from, and make sure NASM is in your PATH or you'll end up with no optimized assembly code. |
||
27th July 2022, 16:49 | #8563 | Link | |
Registered User
Join Date: Apr 2022
Posts: 28
|
Microsoft y u do dis?
TL;DR Is there some magic bullet for muxing an HEVC elementary stream with Open GOP using mp4box and getting Media Foundation to decode it properly?
I'm running into some weird issues with Open GOP HEVC + Media Foundation decoding in an MP4 container. Muxing with ffmpeg -movflags faststart+negative_cts_offsets seems to work fine most of the time. It complains about a lack of timestamps in the raw .hevc stream and outputs VFR, so -i has to be preceded with e.g. -r 60000/1001 to get around that, and I have to -loglevel error -stats or it will just quickly fill the console, ad infinitum, with: Quote:
Is it some kind of IDR signaling issue? Disabling Open GOP alone seemingly resolves all of the issues, but I would like to use Open GOP since these are static camera shots. Is it something really dumb like -inter 500 being too small? I guess that would make me really dumb. It's starting to seem more like a GPAC/mp4box issue, or more likely super-duper Dunning-Kreuger PEBKAC, but I don't know enough about HEVC bitstream output and signaling (PPS/SPS/VUI) to know any better so I wasted my time messing with encoder parameters. MP4Box output is mostly unplayable, it doesn't seek, and it plays choppy, almost like what you'd expect to see when the decoder drops a temporal enhancement layer and plays back at half FPS. Using --forcesync with mp4box didn't help either. I tried MP4Box with an added --negctts but that just outputs "Arg negctts set but not used" in the console - whereas using negative_cts_offsets in ffmpeg seems to fix things?! Either way, the issue only seems to be with Media Foundation playback. Using an MKV and/or decoding with LAV works fine, as does decoding in software or using MPV or even ffplay. --- What about any of the x265 bitstream options, could they help? Based on the documentation, --repeat-headers seems like it's only useful for trying to seek within the elementary stream output before muxing it. --aud? --eos? --hrd? I thought --idr-recovery-sei might help, but enabling it along with --repeat-headers seemingly made things worse. mp4box's output when trying to mux a stream made with those two options makes avidemux crash immediately, and makes ffmpeg (MPV) have serious issues playing the file too. This seems to be regardless of the parameters I tried with mp4box: -inter 0 to force a flat mp4, letting it do the default -inter 500, and trying with and without --forcesync for both options. I am pretty sure I tried --nosei, but that'd just be throwing away the extra stuff I asked x265 to write, and then I'd have to waste my time remembering how to re-signal bt709/limited. Trying to remux any of that mp4box output using ffmpeg results in a file that is entirely unplayable in anything, it skips back and forth randomly, you get intermittently decoded blocks, etc. It's also the only result that could technically allow posting a screenshot, since it's NSFW video...it's VR pr0n alright? I can mux directly from the raw .hevc stream if I use those two x265 options with ffmpeg but only with no other parameters, just forcing the FPS with -r 60000/1001 to prevent erroneous VFR output, and -c copy. I haven't tried -movflags faststart, and using negative_cts_offsets seemingly breaks these files too. I also have yet to try putting ffmpeg's output back through mp4box. I am streaming these from a NAS and would prefer to have the MOOV atom at the beginning of the file, so a working flat mp4 is only "half fixed". What's even weirder is I can take a working mp4 from elsewhere at the same resolution, frame rate, and bitrate, and with seemingly identical x265 settings visible in the SEI, and remux it all I want with mp4box. It doesn't break playback under Media Foundation. The only difference is the version tag for x265 reading 0.0 - these working files were also seemingly muxed with ffmpeg (Lavf58.12.100) or even encoded directly with it using -c:v libx265. Looking at that file, it looks like the only options they passed to x265 were --bitrate 30000 --output-depth 10 --colormatrix=2 --colorprim=2 --transfer=2 --videoformat=5. Everything else is --preset medium defaults. I've just been using --preset medium with some slower options selectively enabled, and some that I thought would help lower bitrate when I thought that was the issue. Code:
--bitrate 20000 --output-depth 10 --level-idc 6 --no-high-tier --rect --amp --tskip --tskip-fast --b-intra --limit-modes --vbv-bufsize 30000 --vbv-maxrate 40000 --analyze-src-pics --rc-lookahead 120 --min-keyint 60 --keyint 600 --fades --video-signal-type-preset BT709_YCC --opt-qp-pps --opt-ref-list-length-pps --opt-cu-delta-qp --limit-sao --selective-sao 1 --sao-non-deblock |
|
29th July 2022, 12:23 | #8564 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
A note for MABS users who build for Zen2/3: add -march=znver2 or -march=znver3 in custom_profile in the local64\etc directory. It gives a slightly better performance for those chips, I think I found it 3-4% better when I tested it on my 3900X.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
1st August 2022, 15:34 | #8567 | Link | |
Registered User
Join Date: May 2009
Posts: 331
|
Quote:
|
|
1st August 2022, 19:23 | #8569 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Quote:
They were all Closed GOP, though, so potentially unrelated to your issue. |
|
24th August 2022, 11:58 | #8573 | Link |
21 years and counting...
Join Date: Oct 2002
Location: Germany
Posts: 716
|
I'm tinkering around with my profiles to gain more speed out of my encodes. The significant rise in electricity cost here in Germany made that decision necessary.
I have a question regarding the "--limit refs" parameter. As there is a huge speed difference between mode 1 and 3 and I was told to better use mode 1 for better quality, I now also tested mode 2 which none of the presets seem to use by default. I got a decent performance increase with mode 2 over mode 1 and tested this with quite a few examples. Can't say I've seen any notable differences in quality so far. I read the docs about the differenct modes, but in all honesty I don't really understand what's written there and how that may affect quality. I always do high bitrate encodes with the "slower" preset as a base and CRF values of 18 or even below. Is there any good reason NOT to use mode 2 over 1 for better performance? |
24th August 2022, 18:42 | #8574 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Quote:
|
|
24th August 2022, 19:03 | #8575 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Quote:
If you use SAO, --selective-sao 2 saves a bit without material quality impact. If you can share your current command line, we might have other suggestions. In general, the --preset options are pretty well tuned for a typical range of content and scenarios as of x265 3.0. They don't include any features added in 3.1 or later, which is why no --selective-sao, --rskip 2, etcetera, even though those really should be the defaults. |
|
24th August 2022, 23:07 | #8576 | Link |
21 years and counting...
Join Date: Oct 2002
Location: Germany
Posts: 716
|
Thank you for those suggestions.
Right now I recode 1080p content I use these settings: Code:
--preset slower --crf 17.00 --qpfile "E:\WORK\chp.qpf" --repeat-headers --input-depth 16 --output-depth 10 --dither --ctu 32 --limit-refs 2 --psy-rdoq 5 --selective-sao 0 --no-sao --colorprim bt709 --transfer bt709 --colormatrix bt709 |
25th August 2022, 01:49 | #8577 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Quote:
There's no point to using --selective-sao if you're already using --no-sao. I always like to set --profile and --level-idc so I'll get warnings if I violate the requirements. In your case that looks like --profile main10 --level-idc 4.0 or 4.1. Using --psy-rdoq 5 without raising --psy as well is an uncommon configuration, but should work. I'd use --rskip 2 to replace the default --rskip 1 because it's a better quality mode. I've not directly compared the speed. Higher --rskip-edge-threshold values are faster, but can reduce quality. I tend to use 2-3 in my stuff, but I'm more biased towards quality/efficiency than your use case. What CPU are you running on? The biggest thing to improve pixels/joule without any quality loss would be --frame-threads 1. Lower values can actually improve quality. You can learn a lot from doing a --csv-log-level 2 and looking at the frame level data. For example, if there aren't a lot of TUs smaller than 8x8 you could reduce --tu-intra-depth and --tu-inter-depth by 1. Recursing all the way down is mostly helpful with content that has sharp details, like text and cel animation. If you have a lot of RAM, increasing --rc-lookahead can improve quality when VBV-limited quite a lot without much negative speed impact. |
|
25th August 2022, 09:38 | #8578 | Link | ||||||
21 years and counting...
Join Date: Oct 2002
Location: Germany
Posts: 716
|
Quote:
Quote:
Quote:
It's barely visible on 4k, but visible on 1080p and almost terrible on SD. Without raising at least --psy-rdoq a little, x265 tends to produce banding in certain flat areas. And sadly my living room TV is very susceptible to that and tends to intensify even the slightest banding compared to my other TVs. So this is somewhat a personal compromise. Quote:
AMD Ryzen 5950x and 3950x. Both with 16 cores/32 threads Quote:
Quote:
Thanks again for your valued input Ben. |
||||||
25th August 2022, 23:13 | #8580 | Link | |
Registered User
Join Date: Oct 2021
Posts: 1
|
Quote:
It's a shame that you have to fiddle with x265 to get an acceptable quality, when a simple --tune film --preset veryslow produces good results with x264. Of course, clean material isn't an issue, it's just that x264 looks better with noise/grain - out of the box. |
|
|
|