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. |
|
|
Thread Tools | Search this Thread | Display Modes |
15th October 2019, 18:26 | #22 | Link | |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
Quote:
Code:
from vapoursynth import core from zoptilib import Zopti orig = core.ffms2.Source(source=r'ridgemont.avi') # lossless intermediate file containing 80-100 single frames throughout the whole movie (see below how I do it) zopti = Zopti(r'results.txt', metrics=['mdsi', 'time'], matrix='709') b = -110/100.0 # optimize b = _n_/100.0 | -175..-50 | b c = -10/100.0 # optimize c = _n_/100.0 | -30..70 | c alternate = core.resize.Bicubic(orig, width=1280, height=688, filter_param_a=b, filter_param_b=c) # this one downsizes the lossless clip to my final size alternate = core.resize.Bicubic(alternate, width=3840, height=2064, filter_param_a=0, filter_param_b=0.5) # this one upsizes the downsized clip to the full 4K resolution as I have a 4K TV orig = core.resize.Bicubic(orig, width=3840, height=2064, filter_param_a=0, filter_param_b=0.5) # the lossless clip (having the original resolution minus black borders) is upsized to 4K zopti.run(orig, alternate) # we compare the upsized original to the downsized-upsized one to get as close as possible clp = core.std.SelectEvery(clp, 700, 1) clp = core.std.Trim(clp, 2, 101) So in this case it would pick one frame in every 700 frames, then trim the result to 100 frames. I do this to make sure the comparison uses various kind of frames throughout the movie. I usually adjust the first line so that the clip length is first something like 105-110 frames, then uncomment the Trim line. Then I use ffmpeg to encode the lossless clip (you can use FFV1 as the codec for example), like vspipe.exe --y4m "yourscript.vpy" - | c:\utils\ffmpeg\bin\ffmpeg.exe -i - -c:v ffv1 "c:\zopti\yourlosslessclip.avi" The idea of the Zopti script is to simulate encoding the video in a lower resolution and then your TV or media player will upsize it to 4K when you watch it. We are trying to find optimal parameters in Bicubic to make sure the distortion in the final result is as small as possible. The other metric to try is gmsd, it's faster than mdsi. Usually ends up in a slightly less sharp final result. This is the Zopti command line I use: zopti test.vpy -alg mutation -iters dyn -dyniters 15 -dynphases 2 -pop 1 -runs 1 -mutcount 1 -mutamount 0.1 0.01 -initial script Then from the log file, get the best result for b and c (filter_param_a and filter_param_b in Vapoursynth Bicubic). Place them in your script that you use to encode. zopti -mode evaluate -log "nameofthezoptilogfilehere.log" It may look a bit complicated but once you do it a few times, you get the hang of it. I'm quite happy with the results, much better than what I could have done manually.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
|
15th October 2019, 19:40 | #23 | Link | |||
Registered User
Join Date: Jan 2019
Location: Russia
Posts: 105
|
Boulder Thank you very much for explaining! Just a few questions.
1) If I'm encoding HDR, should I use: Quote:
2) If i don't use denoising (because i don't know how), can i skip encode the lossless clip and just add to the beginning of the script? Quote:
Quote:
Last edited by redbtn; 15th October 2019 at 20:35. |
|||
15th October 2019, 20:37 | #24 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
If you are going the HDR way, you can use bt2020nc as the matrix and skip the tone mapping part. You can also add those two lines selecting the frames there, but it will probably be slower than using a lossless clip with the frames already picked.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
15th October 2019, 20:43 | #25 | Link | |
Registered User
Join Date: Jan 2019
Location: Russia
Posts: 105
|
I got an error in VS Editor using matrix='bt2020nc'
Quote:
Last edited by redbtn; 15th October 2019 at 20:46. |
|
15th October 2019, 21:41 | #28 | Link |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Unless you're scaling in the linear light domain, you probably aren't going to get great results. I don't know of any way with most open source pipelines to get linear light transforms. I generally wind up doing it with the Adobe Creative Cloud products.
|
15th October 2019, 21:46 | #29 | Link | |
Registered User
Join Date: Jan 2019
Location: Russia
Posts: 105
|
It seems weird, sometimes it writes (no samples)
UPD: Oh, it seems like i found the reason. I use script below and it shows 100 frames, but the duration is still 1 hour 44mins (FPS: 16/1001 = 0.01598), like whole movie. I try to do losless video, and i get *.avi with 1 hour 44mins duration. It's very weird. I don't know what I'm doing wrong. UPD 2: Problem is SelectEvery function. Without it fps is ok (FPS: 24000/1001 = 23.976). I don't know why it's happening. UPD 3: Solution is very simple, Just set AssumeFPS after SelectEvery. Now it's ok. No, it's not. Fps is fine but it still writes "no samples". Maybe this is not errors. The script works and gives the result. Quote:
Last edited by redbtn; 16th October 2019 at 01:21. |
|
16th October 2019, 04:47 | #31 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
Don't worry about any of those things, it's working fine
And when you get the results, don't forget to divide them by 100 to get the value to feed in the resizer. As benwaggoner mentioned, you probably need something like resamplehq with HDR sources (in Zopti and final encode).
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... Last edited by Boulder; 16th October 2019 at 05:57. |
16th October 2019, 18:46 | #32 | Link | |
Registered User
Join Date: Jan 2019
Location: Russia
Posts: 105
|
Quote:
And I have a question, if I wanna spend like 18mb/s of bitrate to all my encodes (If they can use less bitrate for a quality that suits me, I don't care. And if they need more, I don't want to spend more), what the best way, adjust CRF to target bitrate or use ABR? I'm asking because I did test and noticed that CRF encode in slow scenes much worse than ABR. I didn't compare high motions scenes yet, but I'm a little confused. |
|
16th October 2019, 19:36 | #34 | Link | |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
Quote:
If I'm not entirely mistaken, a 2-pass encode at 18 Mbps and CRF resulting in the same average bitrate should produce equal quality. The rate control mechanism is most likely the same, at least that's how it is with x264.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
|
16th October 2019, 19:51 | #35 | Link | |
Registered User
Join Date: Jan 2019
Location: Russia
Posts: 105
|
Quote:
Do you use --cutree? Last edited by redbtn; 16th October 2019 at 20:19. |
|
16th October 2019, 20:52 | #37 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
Yes, cutree is enabled by default. ABR is not suitable for your regular encodes, I'd say it's more for streaming or just some quick tests. Better find the CRF level you are happy with..
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
18th October 2019, 17:23 | #38 | Link | |
Registered User
Join Date: Jan 2010
Location: France
Posts: 851
|
I think I'll go with these settings :
Quote:
Last edited by Nico8583; 19th October 2019 at 10:45. |
|
18th October 2019, 19:34 | #40 | Link |
Registered User
Join Date: Jan 2010
Location: France
Posts: 851
|
I don't know these parameters, hdr-opt and/or colormatrix and/or range don't already define these values ?
And I'm doubting about SAO, with a high bitrate I allways disable it but since last x265 versions perhaps it's not a good idea ? |
Tags |
parameters, presets, settings, x265 |
|
|