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. |
10th April 2021, 13:07 | #61 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Quote:
For me ffmpeg is actually slightly better than AVID encoder. And because I use plain simple test (v210 source directly encoded ) I have no place for any error (except actually ffmpeg issue if exist). And because ffmpeg gives slightly higher PSNR and also when I visually compare in Resolve ffmpeg DNxHR show less difference I simply don't believe in your tests (your path is full of possible issues- it involves so many "engines"). Yes, but atm. ffmpeg has no HQX encoder- just decoder, so it won't happen. Last edited by kolak; 10th April 2021 at 13:31. |
|
10th April 2021, 14:49 | #62 | Link |
Registered User
Join Date: Oct 2014
Posts: 209
|
Thanks a lot Kolak for your extensive and well understandable explanations!
With your and poisondeathray's help I was able to understand the traps of the workflow and how I can handle them. With respect to my intended workflow Camera > Edius > AVS+ > Edius would you be so kind to check if these conclusion sounds basically consistent to you: - My camera delivers H.264 YUV422 10bit. I should always record in rec709 with full luminance range - I learned my NLE has a YUV engine. I can use the Primary Color Correction filter, no need to be concerned about that as possible conversion loss is not relevant in the amateur field - Export HQX superfine 10bit as MOV is ok. I am staying in YUV - Import into avs+ with LSMASH in YUV422P10. Check that rec709 arrives. If not, convert it. - whenever possible use 16-bit AVS+ YUV422 capable filters - to monitor interim results in VDub2 convertToRGB24(matrix="pc.709"). (monitor only, not for export) - Compress the result with appropriate YUV422 10bit codec to import back into Edius (both of us seem to like ffmpeg DNxHD ) And if you finally could tell what PSNR means and how you can measure it (as amateur) - would be great. Thank you so much. Last edited by Hotte; 10th April 2021 at 15:07. |
10th April 2021, 15:33 | #63 | Link | |||||||
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
-Compare v210 instead of HQX. There are also detail differences. Is that from jpeg, or decoder differences for GV HQX ? -There are slightly different algorithms to convert YUV422P10 to RGB . For example, chroma upsampling algorithm. (one might use bicubic, one might use slightly different coefficients of bicubic, or bilinear etc...). Chroma center location interpretation. Avisynth internal resizers use "center" instead of "mpeg2". You can use z_convert_format (avsresize) instead of ConvertToRGB(blah). You're just using it for a rough "preview" instead of vdub's 601 preview, so it shouldn't matter too much If you want to include other accurate testing - use 10bit colorbars . 10bit colorbars should reproduce exact 8bit RGB colors as per rp219. Also include some other test material like gradients in your workflow to debug things end to end Quote:
If you perform a colormatrix transform in YUV integer (8bit, 10bit, 16bit) - it's not lossless, not 100% reversible. If you do it in float, it can be a lossless transform. Converting to 10bit YUV to 8bit RGB is not lossless. (You're just using it as a rough "preview") Quote:
Quote:
But final version should always be "standard" range. So fast turn around situations (direct to TV, broadcast ENG) never use "full range" for acquistion Quote:
Vapoursynth can do this correctly. In order to be 100% lossless the chroma up/down sampling has to use nearest neighbor algorithm, and float used on all calculations But these are relatively minor issues. Don't loose sight of the "big picture" as Kolak said Quote:
Quote:
One way can use ffmpeg to measure https://en.wikipedia.org/wiki/Peak_s...to-noise_ratio https://ffmpeg.org/ffmpeg-filters.html#psnr It's not a good measure for subjective testing, but it's excellent to determine if something is lossless or not (infinity dB) |
|||||||
10th April 2021, 15:43 | #64 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
If Rec.709 and Rec.601 gamuts are slightly different how can you guarantee lossless conversion (I assume you don't clamp to gamut limits)?
PSNR may not be good measure for heavy compression but it's ok for intermediate codecs as in this cases differences are more mathematical than perceptual (overall differences are small and quite often not visible at 1:1 frame). |
10th April 2021, 15:50 | #65 | Link | ||
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
There are no "limits" to float, nothing is clamped Quote:
|
||
10th April 2021, 15:59 | #66 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
ffmpeg -i ref_source -i source -filter_complex psnr -f null -
this how you do it with ffmpeg. At the end you get stats. Anything within +-3dB is not a very meaningful difference. Eg ProRes may show average PSNR of 56dB and DNxHR 54dB. For clean good quality sources (like my BRAW 12K sample downscaled to HD) PSNR can go above 60dB which means loos is very small. For difficult scenes PSNR for intermediate codecs can go <50dB. You can read about HQX here in its whitepaper: https://www.syntex.sk/media/document...whitepaper.pdf you also have Apple white paper about ProRes which has very similar results: https://www.apple.com/final-cut-pro/...hite_Paper.pdf ) you have PSNR graphs against other codecs. GV uses same source as Apple (STEM footage), which is specially prepared footage for digital cinema validation. It's never compressed (shot on 35M film) source which is very important. I use to have access to it- very demanding source. If you take some source from the internet (which you have no idea how it was shot) your results can be very misleading. You may get some nice source which was shot on eg. ALEXA in ProRes natively. Then if you convert that to ProRes then it's 2nd generation fo the same codec and your PSNR will be very high. It won't be true for other codecs as they use different math. You have to really know what you are doing in those tests as you can easily produce something very false Cineform behaves quite differently on uncompressed sources with original noise/grain compared to source which are already went through DCT based compression (so ProRes, DNxHR etc). Internet is full of fundamentally flawed tests. Last edited by kolak; 10th April 2021 at 16:10. |
10th April 2021, 16:01 | #67 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
But Re.709 gamut doesn't 100% align with Rec.601, so how can you represent color from Rec.709 gamut (which is not part of 601) in Rec.601 and then get it back?
Last edited by kolak; 10th April 2021 at 16:15. |
10th April 2021, 16:17 | #68 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
(-) values and values > 1.0 are retained in float It works, you can compare with PSNR and diff . You'd have to run some matlab calculation to test every single iteration and combination to verify, but it's lossless in every synthetic and camera acquisition clip I've tested |
|
10th April 2021, 16:18 | #69 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Quote:
They improved it and made v210 to v210 (if we do pure transcode process) not going to RGB at all I think (may be true for other YUV based codecs). |
|
10th April 2021, 16:23 | #70 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Quote:
There is no way that certain color can go from Rec.709->Rec.601->Rec.709 as this color doesn't exist in strict Rec.601 gamut. It's like you had P3 gamut, converted to strict Rec.709 and then back. No way it can be ever lossless. Last edited by kolak; 10th April 2021 at 16:25. |
|
10th April 2021, 16:24 | #71 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
On one hand, yes, code values 0,1023 are reserved for sync, important for equipment - but for synthetic tests could argue a codec should not artifically limit a range It's a bit inconsistent handling, because ffmpeg dnxhr does not limit the range. Neither do official implementations of v210 or dnxhr |
|
10th April 2021, 16:27 | #72 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Quote:
Eizo monitors even have setting which either passes 1:1 or stretches 4-1019 to full 0-1023 range. FFmpeg probably follows Apple official encoder (and Apple follows some SMPTE/EBU etc specs). Not a fan of those "reserved bits" - they only produce confusion Last edited by kolak; 10th April 2021 at 16:39. |
|
10th April 2021, 16:33 | #73 | Link | |||
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Think about it - you're not producing a file in float. It's for intermediate. You're not clamping anything Recall , the topic was question was changing 709/601 in YUV. A colormatrix transform, as if the file in YUV had used 709 instead (or 601 instead) The background info was intermediate RGB preview (recall vdub uses 601) , was different than using 709 Quote:
|
|||
10th April 2021, 16:39 | #75 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Yes, but "v210" exported from Adobe, Resolve , etc, retain 0-1023 code values. ffmpeg v210 does not. Do you see the problem ? Yeah, it's not important in the big picture; but you better believe that "little detail" becomes important when testing decoders, psnr . Details matter. I reported it before on ffmpeg bug tracker. Nobody seems to care At the very least there is inconsitent behaviour within ffmpeg, and between professional apps |
|
10th April 2021, 16:41 | #76 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Yep, definitely wasn't aware ffmpeg does it in such a selective manner.
PSNR on v210 out of Resolve encoded to v210 in ffmpeg is still inf. PSNR on DNxHR encoded to v210 in ffmpeg is still inf. Last edited by kolak; 10th April 2021 at 16:53. |
10th April 2021, 17:15 | #77 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Check if your original code values had Y <4, >1019 to begin with. Make sure export had "retain sub-black...superwhite" enabled if using resolve Verify in other programs that the code values are there with the export. (e.g. vapoursynth, vsedit colorpicker, or avisynth can now with histogram(bits=10)) I use a wrapper function to turn right , left Thisto(10) Code:
function THisto(clip c, int "bits") { bits = Default(bits, 8) c.TurnRight().Histogram(bits=bits).TurnLeft() } ffmpeg v210 encoder is definitely not "infinity" on a ramp, and you can see it on the waveform in multiple programs. You don't need PSNR to know it's not lossless. You can see it. Even ffmpeg's own -vf waveform detects the discrepancy. To be clear, ffmpeg can still DEcode 0-1023 from other formats e.g. if you test 10bit422 AVC input, it still outputs 0-1023 raw values. But if you encode a v210 version , that will only contain 4-1019 values. Let me know if me to upload a demo package (When using ffmpeg psnr, it's good idea to reset timebase - different containers use different timebases and this can cause ffmpeg to compare different frames (not important for 1 frame obviously, but when testing "video")) This is a 0-1023 ramp test. Resolve v210 vs. original v210 ffmpeg -r 24 -i 1_resolve_v210.mov -r 24 -i 0_1023x720_0-1023.mov -lavfi "[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]psnr" -f null - [Parsed_psnr_4 @ 00000027ffcb73c0] PSNR y:inf u:inf v:inf average:inf min:inf max:inf FFmpeg v210 vs. Resolve v210 ffmpeg -r 24 -i 2_ffmpeg_v210.mov -r 24 -i 1_resolve_v210.mov -lavfi "[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]psnr" -f null - [Parsed_psnr_4 @ 0000001488292ec0] PSNR y:72.519000 u:inf v:inf average:75.529300 min:75.529300 max:75.529300 |
|
10th April 2021, 17:35 | #79 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Here is a 10bit ramp package. 1024x720 perfect ramp. Each column corresponds to pixel value in Y'
https://www.mediafire.com/file/cvulp...tests.zip/file 0_1023x720_0-1023.mov is "original" 1_resolve_v210.mov is original exported from resolve 2_ffmpeg_v210.mov is generated from ffmpeg -i 1_resolve_v210.mov -c:v v210 -an 2_ffmpeg_v210.mov e.g ffmpeg -vf waveform ffmpeg -i 1_resolve_v210.mov -vf waveform=g=green 1_resolve_v210.png ffmpeg -i 2_ffmpeg_v210.mov -vf waveform=g=green 2_ffmpeg_v210.png |
10th April 2021, 17:58 | #80 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Got it now- those ramp generators in Resolve/Premiere are crap
So this is basically v210 encoder and ProRes encoder (and decoders are passing whatever is there)? Also- both Resolve and Premiere are quite crap when it comes to trying to see it. Resolve parade shows for both files same result, so it means it's probably made to skip those reserved values! Interesting. There is always some new crap coming out DNxHR encoder in my ffmpeg also clips them (4.3.2). It doesn't do for Cineform though. Last edited by kolak; 10th April 2021 at 18:25. |
|
|