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. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
|
|
#1 | Link |
|
Registered User
Join Date: Apr 2024
Posts: 517
|
zscale WEBP Error
But when I tried to used zscale when converting a video to lossless animated WEBP, I got this error:
Code:
[Parsed_zscale_0 @ 0000020b7458bd80] code 3074: no path between colorspaces
Last message repeated 25 times
[vf#0:0 @ 0000020b74005240] Error while filtering: Generic error in an external library
[vf#0:0 @ 0000020b74005240] Task finished with error code: -542398533 (Generic error in an external library)
[vf#0:0 @ 0000020b74005240] Terminating thread with return code -542398533 (Generic error in an external library)
[vost#0:0/libwebp_anim @ 0000020b74004700] Could not open encoder before EOF
[vost#0:0/libwebp_anim @ 0000020b74004700] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libwebp_anim @ 0000020b74004700] Terminating thread with return code -22 (Invalid argument)
[out#0/webp @ 0000020b74004380] Nothing was written into output file, because at least one of its streams received no packets.
frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!
Here is the information for the video: Code:
Format : AVC Format/Info : Advanced Video Codec Format profile : High@L4.1 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Format settings, Slice count : 4 slices per frame Codec ID : V_MPEG4/ISO/AVC Duration : 10 s 886 ms Bit rate mode : Variable Maximum bit rate : 40.0 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 23.976 (24000/1001) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Time code of first frame : 01:37:05:07 Default : Yes Forced : No Code:
ffmpeg -i video.mkv -vf zscale=pin=2:p=2:tin=2:t=2:min=709,format=bgra output.webp |
|
|
|
|
|
#3 | Link | |
|
Registered User
Join Date: Aug 2024
Location: Between my two ears
Posts: 998
|
Quote:
|
|
|
|
|
|
|
#5 | Link | |
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
Only the expected rounding errors. Not the additional errors on top of the expected ones like default swscale without accurate flags You expect some accuracy and rounding issues with 8bit YUV to 8bit RGB. This is discussed in other threads in detail. The only way it's completely lossless is if you use RGB float and use nearest neighbor for chroma scaling. This preserves negative RGB values, and values over 1 on a 0 to 1 scale. This can be "reversed" as a lossless round trip so you get the original 8bit YUV data |
|
|
|
|
|
|
#6 | Link | |
|
Registered User
Join Date: Aug 2024
Location: Between my two ears
Posts: 998
|
Quote:
I don't think rounding errors disqualify the point of lossless encoding though, I mean of course no rounding error is much more optimal but lossless encoding prevents generational loss and other stuff as well. Last edited by Z2697; 10th December 2024 at 14:56. |
|
|
|
|
|
|
#7 | Link | ||
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
Quote:
The encoding itself is lossless, but if the operations used to convert to RGB cause a color shift compared to the expected values, it's incorrect . =>The incorrect values and color shifts are preserved losslessly ![]() My point was if you're going to jump through the hoops for a lossless workflow, why introduce other avoidable errors and color shifts and preserver them ? Last edited by poisondeathray; 10th December 2024 at 16:05. |
||
|
|
|
|
|
#8 | Link | ||
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
Do you have the same values or not ? That' s one definition of losslessness You can argue some values "shouldn't be there", but your feelings do not define whether or not something is lossless ![]() Quote:
8bit RGB to 10bit YUV can be a lossless conversion if done properly, because you can get back the original 8bit RGB values But 8bit YUV to 8bit RGB - you cannot get back the original 8bit YUV values, so it's not lossless conversion The other point you probably missed is many 8bit YUV map to the same 8bit RGB value irrespective of the out of gamut values. The precision is not high enough. 10bit YUV is required for the original, original 8bit RGB source if that was your reference point |
||
|
|
|
|
|
#10 | Link |
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Out of gamut errors are the YUV values that map outside of the RGB defined color cube. eg. 8bit YUV value maps to something less than RGB 0 or greater than RGB 255
You can argue that YUV value shouldn't have been there in the first place - and I agree with you - but that has no bearing on whether something is "lossless" or not The 8bit YUV precision errors are different category than out of gamut . You can have several YUV values that map to the same RGB value which are in gamut , in the range [0-255] |
|
|
|
|
|
#11 | Link | |
|
Registered User
Join Date: Aug 2024
Location: Between my two ears
Posts: 998
|
Quote:
How does 8 bit YUV (originated from 8 bit RGB, but of course not full 8 bit RGB values are represented) to 8 bit RGB is not "lossless", even when there's less precision in the source? |
|
|
|
|
|
|
#12 | Link | ||
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
eg. Your point of reference is is 8bit RGB. If you convert to 10bit YUV, you can get back the original 8bit RGB values 8bit RGB => 10bit YUV => 8bit RGB can be lossless if done properly Quote:
If the 8bit YUV is considered the "source" or starting point - after you do a conversion, can you get back the same values or not ? That's what "lossless" means - you have the same values. 8bit YUV => 8bit RGB is not lossless because you cannot get back the 8bit YUV values Similarly, all these steps are lossy and not reversible, you cannot get back any of the original values from a preceding step 8bit RGB original, original source => 8bit YUV (already lossy compared to previous step) => 8bit RGB (2 generation lossy steps) Last edited by poisondeathray; 10th December 2024 at 18:43. |
||
|
|
|
|
|
#13 | Link | |
|
Registered User
Join Date: Aug 2024
Location: Between my two ears
Posts: 998
|
Quote:
I keep saying my reference point is YUV (originated from RGB, but the loss is done, doesn't matter at all now), and you just keep saying my reference point is RGB. What can I say. You have your "if done properly", I have mine. Let's not bother it too much. |
|
|
|
|
|
|
#14 | Link | |
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
ie. 8bit YUV (from a 8bit RGB source) to 8bit RGB is still lossy, when using 8bit YUV as the reference point - for the reasons already mentioned. If you want definitive proof, you can test with all 16777216 8bit RGB color combinations as a pre starting point (A) - all "out of gamut values" are culled by definition Make your 8bit YUV444 starting point (B), and convert to 8bit RGB (C) - There is no way you can get back the YUV444 (B) , (or original RGB colors (A) ), from (C) You can generate the pattern see this thread , or use ffmpeg allrgb https://forum.doom9.org/showthread.php?t=183816 https://ffmpeg.org/ffmpeg-filters.ht...02c-yuvtestsrc For (C) - the attempt to convert back to YUV444P8 to achieve (B) "your" original values, the PSNR is about 86db. It would have been infinity if it was lossless for ffmpeg psnr. Now slightly different methods will give slightly higher or lower, but it's always expected to be lossy (unless you have some weird source with 1 color that just happens to map correctly) |
|
|
|
|
|
|
#15 | Link |
|
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,389
|
Yes but the scenario you're describing has more to do with the fact that you have out of range values than it has to do with RGB in general, but I understand your logic.
One however could therefore argue that scaling YUV to Studio RGB (that is, RGB in limited TV range) is therefore lossy 'cause both of them are limited. In other words: YUV Limited TV range to Studio RGB limited TV range = lossless YUV Full PC range to RGB full PC range = lossless YUV Limited TV range to RGB Full PC Range = lossless as long as the original YUV stays within 0.0-0.7V, as it should. In general, even when you're receiving a feed from your favourite TV station, letting anything get to out of range values, so above 0.7V (i.e 700 mV) or 235 for those who prefer the 8bit value reference is a sin 'cause all customer's TV are RGB anyway, so they would lose whatever is above 235 as that value is expanded to 255 and you run out of room. One of the things that is generally done is the soft highlights rollback to basically dim down the highlights of the elements going out of range to make them get back within the limited TV range. Even during live events, where you have potentially fast and unpredictable movement compared to interviews, you generally regulate the thing and then you put hardware clipping on the signal in anyway. This is checked using real time hardware waveform monitors like the ones from Tektronix https://imgur.com/HRLItw3 and is what led me to create VideoTek() in Avisynth https://forum.doom9.org/showthread.php?p=1832846 - https://github.com/FranceBB/VideoTek Last edited by FranceBB; 11th December 2024 at 08:06. |
|
|
|
|
|
#16 | Link | ||
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
"out of gamut" is a separate topic than "legal range" , "full range" . You can produce out of gamut values, even when you have legal range YUV values Quote:
Prove it to yourself. Start with that RGB image in the post above and run through these 3 scenarios . Make sure you use YUV444P8 so we avoid discussing subsampling issues for now Even if you remove out of gamut values - 8bit YUV => 8bit RGB does not have enough precision to map to a specific RGB value - there are multiple YUV values that map to a single RGB value that is within gamut. You end up with +/- 3 errors , and rounding errors. This is one of the contributing reasons behind 8bit "banding" . With 10bit YUV, there is enough precision to map exactly to each 8bit RGB 16777216 values |
||
|
|
|
|
|
#18 | Link | |
|
Registered User
Join Date: Aug 2024
Location: Between my two ears
Posts: 998
|
Quote:
The real problem is rounding. Take 8bit RGB value (210,87,0) as example. When converted to full range 8bit YUV using BT.709 matrix you get (107,70,193), the "floting point" result is (0.419092,-0.225852,0.256818). When this 8bit YUV value takes a roundtrip, the 8bit RGB value is (209,87,0), the 8bit YUV value is (107,71,193), fp result is (0.418258,-0.225403,0.254858) (which if +0.5*255 is (106.65579,70.022235,192.48624) I don't know why zimg (vapoursynth core.resize) rounds the 8bit value this way, or I'm doing the math wrong, but you get the point, I guess) There's only a small fraction of this kind of values, most of them in "extreme values" like the Blue being 0 in the example, so if the image does not contain such pixels or some special treatment is done to the image, the 8bit YUV to RGB converion can be lossless. You don't need very special "1 color" image to achieve that. 10bit YUV lossless"ness" is much easier to achieve. But if any postprocessing including encoding is done to the image the lossless"ability" will likely be ruined even for 10bit. |
|
|
|
|
|
|
#19 | Link | ||||
|
Registered User
Join Date: Sep 2007
Posts: 5,669
|
Quote:
The analogy would be like a 3 different YUV pixel "mail delivery addresses" to 3 different RGB pixel "house numbers" 101,102,103 (simplified example, consider just 1 channel for now, not a RGB triplet). Because 8bit YUV precision isn't high enough you end up getting something like RGB 101,101,103 - which is one of the reasons you get 8bit "banding " - multiple YUV values can map to the same RGB number. From that RGB 101,101,103 , there is no way you can go back to 3 different original YUV numbers using standard methods from 2 duplicate, 1 unique RGB pixels (maybe using "AI" or guessing) Quote:
- I have to include that because there are many ways, in many software, where it can go wrong )Quote:
The fact is 99.99% of of type "regular" YUV sources for a YUV starting point will not be lossless for 8bit YUV to 8bit RGB conversion , and have many pixel values that become "lossy", changing from the original values Because in real life , many more "problematic" YUV values occur naturally : - chroma resampling . Chroma resampling to generate the YUV 4:2:0 "source" can produce millions of values that were "good" YUV values that will become "bad" YUV values and lossy in the round trip when tested against the YUV 4:2:0 source. (I'm not referring to duplicating and discarding using nearest neighbor for the RGB step, I'm referring to generating different YUV values due to resampling a pre non subsampled source to the 420 source by resampling say, a 4x4 grid of pixels using bicubic ). Most "sources" will be 4:2:0, and that is hardly considered "special treatment" - lossy compression (most sources you start with are going to have lossy compression), multiple generations. Even if a value is slightly off due to lossy compression in a channel from "good" YUV triplet from a prior lossless conversion, that can cause next RGB conversion step to go out of gamut , which makes it irreversible Millions of "bad" YUV values occur within "legal range" Y 16-235 CbCr 16-240 that can produce out of gamut RGB and clip (and therefore not reversible, not lossless) . There are fewer that occur in a full range conversion but they still potentially in the number of millions. Quote:
To be clear - 10bit YUV "losslessness" refers to 8bit RGB => 10bit YUV. By definition , all the "illegal" , out of gamut such as negative RGB values are already "culled" from 8bit RGB source. ie. all 8bit RGB 16777216 values can be properly and precisely coded for with 10bit YUV. It should be always lossless for all 8bit RGB values (when done properly )
Last edited by poisondeathray; 12th December 2024 at 21:17. |
||||
|
|
|
|
|
#20 | Link | |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,442
|
Quote:
|
|
|
|
|
![]() |
| Tags |
| colorspace, colorspace conversion, ffmpeg |
| Thread Tools | |
| Display Modes | |
|
|