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. |
9th March 2024, 11:35 | #1 | Link |
Registered User
Join Date: Dec 2023
Posts: 2
|
StaxRip cut one pixel border
Hi all,
I have videos where there are black borders one pixel thick at the top and bottom. Normally I would leave these in when I encode, but I wonder if there might be a solution after all. When I try to remove a pixel at the top and bottom with the crop function in StaxRip, I get the following error message: Crop: YUV image can only be cropped by Mod 2 (top) Is there another option? Adding a bar with one pixel and then cutting 2 pixels doesn't work either. Maybe it is possible to move the video up one pixel without the bars and then cut 2 pixels at the bottom? |
9th March 2024, 12:18 | #2 | Link |
RipBot264 author
Join Date: May 2006
Location: Poland
Posts: 7,888
|
ConvertToRGB
Crop(0,1,0,-1) ConvertToYv12
__________________
Windows 7 Image Updater - SkyLake\KabyLake\CoffeLake\Ryzen Threadripper |
7th October 2024, 07:10 | #5 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,934
|
You can use a resizer to crop a single pixel or less, although the dimensions would still need to be at least mod2.
I'm not sure it'd remove the lines completely though. It'd depend on the value of the chroma samples at the edges. Then again, the same probably applies to converting to YUV444 or RGB and back in order to crop. If the source video was 1280x720, for example. Spline36Resize(1280,718, 0,1,0,-1) Depending on the resizer, the luma (Y) seems to remain untouched either way. A = ConvertToYUV444().Crop(0,1,0,-1).ConvertToYUV420().ExtractY() B = Spline36Resize(1280,718, 0,1,0,-1).ExtractY() Compare(A, B) The result for the chroma would be different, as if you're not converting to YUV444 and back it would only be resampled once. A = ConvertToYUV444().Crop(0,1,0,-1).ConvertToYUV420().ExtractU() B = Spline16Resize(1280,718, 0,1,0,-1).ExtractU() Compare(A, B) Out of curiosity though, does anyone know why not every resizer appears to leave the luma intact, namely GaussResize with a "P" value less than 100 and also BicubicResize? I would've thought that if you're cropping whole pixels and the output dimensions are the same as the cropped dimensions, the resizers should always leave it alone. A = ConvertToYUV444().Crop(0,1,0,-1).ConvertToYUV420().ExtractY() B = BicubicResize(1280,718, 0,1,0,-1).ExtractY() Compare(A, B) Or maybe to be certain the luma is only cropped? Once again assuming a 1280x720 source. Video = last Y = Video.ExtractY().Crop(0,1,0,-1) U = Video.ExtractU().BicubicResize(640,359, 0, 0.5, 0, -0.5) V = Video.ExtractV().BicubicResize(640,359, 0, 0.5, 0, -0.5) CombinePlanes(Y, U, V, planes="YUV", source_planes="YYY", pixel_type="YUV420") Last edited by hello_hello; 7th October 2024 at 08:03. |
7th October 2024, 18:15 | #6 | Link | |
Acid fr0g
Join Date: May 2002
Location: Italy
Posts: 2,809
|
Quote:
__________________
@turment on Telegram |
|
11th October 2024, 21:56 | #7 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,934
|
I don't think it'd be that, because the Avisynth resizers don't mess with the color space or gamma, they just resize as far as I know.
This is what it says on the Avisynth wiki: http://avisynth.nl/index.php/Resize#Notes AviSynth has completely separate vertical and horizontal resizers. If input is the same as output on one axis, that resizer will be skipped. The resizer with the smallest downscale ratio is called first; this is done to preserve maximum quality, so the second resizer has the best possible picture to work with. The "resizer will be skipped" part seems to be correct, except for BicubicResize and GaussResize, although if P=100 for GaussResize, then it does seem leave the video untouched when it's not having to resize. |
12th October 2024, 13:37 | #9 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,934
|
Do you mean ResampleHQ?
Because it's possibly technically more correct to resize in linear light, so RessampleHQ would (I assume) convert from gamma-compressed YUV to linear light RGB, do the resizing, then convert back to gamma‐compressed YUV. Avisynth's resizers just resize without doing any of that. Is that what you're asking? |
15th October 2024, 08:55 | #11 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,934
|
I never downscale enough to worry about it myself, plus is does involve converting to RGB and back, which isn't lossless even if you weren't resizing.
I did experiment a bit with linear light resizing quite a while ago. I managed to find the post at VideoHelp where I uploaded some screenshots, so I'll repost the images as links here. The 1440x1080 source was downscaled to 480x360 with various resizers and then upscaled to 1440x1080 again using Spline36Resize. One thing I did notice was linear light resizing tended to make the lines more jagged after the video was upscaled again. I don't know why, although I did find a setting using DitherTools that seemed to help with that. It's animation, and the main difference is in the high contrast areas, such as the white lines used to show the smoke from the pitcher's cigar in this example. Source https://forum.videohelp.com/attachme...chmentid=61901 CropResize(480,360, 242,0,-242,0, Resizer="Spline36") Spline36Resize(1440,1080) https://forum.videohelp.com/attachme...chmentid=61902 CropResize(480,360, 242,0,-242,0, Resizer="DitherToolsLinear") Spline36Resize(1440,1080) https://forum.videohelp.com/attachme...chmentid=61903 CropResize(480,360, 242,0,-242,0, Resizer="FMTConvLinear") Spline36Resize(1440,1080) https://forum.videohelp.com/attachme...chmentid=61904 CropResize(480,360, 242,0,-242,0, Resizer="ResampleHQ") Spline36Resize(1440,1080) https://forum.videohelp.com/attachme...chmentid=61907 Not much difference between the linear light resizing methods above, but they do retain detail in high contrast areas more then just downscaling with Spline26Resize. The DitherTools settings that didn't make the lines more jagged than downscaling with Spline36Resize were: CropResize(480,360, 242,0,-242,0, Resizer="DitherToolsLinear", RStr=""" SigmoidS=true, CurveS="1886" """) Spline36Resize(1440,1080) https://forum.videohelp.com/attachme...chmentid=61942 I think you'd really do need to downscale quite a lot to care about linear light resizing. For the record, these are the DitherTools and FMTConv functions I used. Code:
function DitherToolsLinear(clip Source, \ int Width, int Height, float "src_left", float "src_top", float "src_width", float "src_height", \ string "Kernel", string "CurveS", string "CurveD", float "GCorS", float "GCorD", \ bool "SigmoidS", bool "SigmoidD", float "ThrS", float "ThrD", float "ContS", float "ContD", \ bool "LSBIn", bool "LSBOut") { Kernel = default(Kernel, "Spline36") CurveS = default(CurveS, "709") CurveD = default(CurveD, CurveS) GCorD = default(GCorD, GCorS) SigmoidS = default(SigmoidS, false) SigmoidD = default(SigmoidD, SigmoidS) ThrD = default(ThrD, ThrS) ContD = default(ContD, ContS) LSBIn = default(LSBIn, false) LSBOut = default(LSBOut, LSBIn) Input = !LSBIn ? Source.Dither_convert_8_to_16() : Source Resized = Input\ .Dither_y_gamma_to_linear(curve=CurveS, gcor=GCorS, sigmoid=SigmoidS, thr=ThrS, cont=ContS)\ .Dither_resize16(Width, Height, src_left, src_top, src_width, src_height, kernel=Kernel)\ .Dither_y_linear_to_gamma(curve=CurveD, gcor=GCorD, sigmoid=SigmoidD, thr=ThrD, cont=ContD) Resized = !LSBOut ? Resized.DitherPost() : Resized return Resized } Code:
function FMTConvLinear(clip Source, int Width, int Height, \ float "src_left", float "src_top", float "src_width", float "src_height", \ string "Kernel", string "CurveS", string "CurveD") { Kernel = default(Kernel, "Spline36") CurveS = default(CurveS, "709") CurveD = default(CurveD, CurveS) Resized = Source\ .fmtc_bitdepth(bits=16)\ .fmtc_resample(css="444")\ .fmtc_matrix(mat=CurveS)\ .fmtc_transfer(transs=CurveS, transd="Linear")\ .fmtc_resample(Width, Height, sx=src_left, sy=src_top, sw=src_width, sh=src_height, kernel=Kernel)\ .fmtc_transfer(transs="Linear", transd=CurveD)\ .fmtc_matrix(mat=CurveD)\ .fmtc_resample(css="420")\ .fmtc_bitdepth(bits=8) return Resized } Last edited by hello_hello; 15th October 2024 at 08:57. |
Tags |
border, cut, one pixel, staxrip, video |
Thread Tools | Search this Thread |
Display Modes | |
|
|