Log in

View Full Version : Quick Downsize/Resize Encoding Question


Seraphic-
4th September 2008, 01:16
Hi,

I encoded a video the a resolution of 1280x716. But now I'm looking to encode another with half the resolution so it has a smaller file size for those with slow connections and less powerful systems.

So was going to do 640 for width. But half of 716 is 358 (which is mod2 when it was mod4 for the original). Should I resize to 356, resize to 358 and crop two from the top for, or just leave it at 358?

Was thinking resize to 358 and crop two pixels from the top, but wanted to ask for some other thoughts as how to do the least damage possible. Spline36Resize(640,358,0,2,0,0)

Thanks

Sagekilla
4th September 2008, 01:26
What's the source resolution? If the source is 1280x716 native also, then go with 640x358 followed by a crop of 2.

Sharktooth
4th September 2008, 01:26
having a mod 16 res is always better coz some avs filters work on mod 16 resolutions only. also non mod 16 res will have a hit (very small though) on the encoder efficiency (assuming the encoder handles non mod 16 res... x264 does though) and may also cause problems on some decoders (expecially those DXVA enabled...). so i would definatly resize/crop to 352 (which is mod 16). 6 pixels are hardly noticeable.

akupenguin
4th September 2008, 01:28
358 is a better resolution than 356, since 358%16 = 6 > 356%16 = 4.
So your choices are:
* resize to 352 and set aspect ratio
* resize to 358 and crop 6
* resize to 358

Seraphic-
4th September 2008, 02:43
Here is the video right here: http://www.seraphicgate.com/index.php?id=51

Well, the native source for the capture is 1280x720, but I always crop to visible pixels, which in this case was 1280x718.
However, my understanding was that mod4 is always better then mod2, so I cropped the extra two pixels.

Thanks for the feedback. Guess I'll go with resize to 358 and crop 6 or maybe keep it at 358.

Sharktooth
4th September 2008, 03:03
i'd go for 352 since you let your users download the videos and you dont know in what player they will attempt to watch it. as i said, some players make use of DXVA and may require mod16 res. in that case if the video is not mod16 they will have problems (black screen, frames corruption, etc...).

ajp_anton
4th September 2008, 03:30
Why would DXVA require mod16? Aren't all Blu-rays and HD DVDs 1920x1080 which is mod8?
If there are 1280x718 visible pixels, you get 640x359 which rounded to nearest mod4 is 640x360. This is also mod8.

Sharktooth
4th September 2008, 03:32
1920x1088 -> 1920x1080

ajp_anton
4th September 2008, 06:24
640x368 -> 640x360

I thought all non-mod16 encodes were really mod16 with some pixels cropped off...

Sharktooth
4th September 2008, 13:03
i meant... 1080p is is really 1920x1088, which is mod 16... the 8 pixels are cropped by the decoder

Seraphic-
4th September 2008, 13:56
On a side note, when as mod2 been acceptable for x264 encoding?
Made a lot of inquiries here and searching Google about cropping and always seemed to get back that you should almost never use mod2 as even software players could have issues and you should be using at least mod4.
Was that wrong?

kemuri-_9
4th September 2008, 14:49
mod4ness is more of a requirement of some of the various YUV colorspaces.
4:2:0 - YV12 (analog) / YCbCr (digital) the common format for numerous encoders,
having mod 4 width and mod 2 height requirements.
x264 accepts this, as long as you don't hit the various square/rectangular minimum frame size requirements.

both MPC-HC (non DXVA)/ffdshow and CoreAVC handled mod4 Width and mod2 Height videos, as long as you don't hit their minimum frame size requirements.

since i'm not familiar with YUV 4:4:4, 4:2:2, or 4:1:1
couldn't tell if you they have smaller requirements than height and width mod4ness.

Comatose
4th September 2008, 15:14
i meant... 1080p is is really 1920x1088, which is mod 16... the 8 pixels are cropped by the decoder
Uhh yeah, but the padding and cropping would happen here also.
It's the same D:

Sharktooth
4th September 2008, 15:33
but all dxva decoders can decode it without problems coz it's mod16.

Comatose
4th September 2008, 15:54
i'd go for 352 since you let your users download the videos and you dont know in what player they will attempt to watch it. as i said, some players make use of DXVA and may require mod16 res. in that case if the video is not mod16 they will have problems (black screen, frames corruption, etc...).
Why would DXVA require mod16? Aren't all Blu-rays and HD DVDs 1920x1080 which is mod8?
If there are 1280x718 visible pixels, you get 640x359 which rounded to nearest mod4 is 640x360. This is also mod8.
i meant... 1080p is is really 1920x1088, which is mod 16... the 8 pixels are cropped by the decoder

That's what I meant. 640x359 (358) is the same as 1920x1080 when it comes to non-mod16ness.

Sharktooth
4th September 2008, 16:15
nope. the decoder will automatically crop 1088 to 1080.... it wont do it for other resolutions.

Sagekilla
4th September 2008, 16:17
I don't believe there's a huge difference between 1920x1080 and and say 640x360 -- Both are mod16/mod8 in their respective dimensions, and x264 will pad to 1920x1088 or 640x368 Only difference is most decoders will automatically think to crop out the last 8 lines if the input is 1920x1088. I'm not so sure if they will automatically remove any padding that was because of x264.

Sharktooth
4th September 2008, 16:48
they will if it's signaled since x264 will always work with mod16 res... it will do some padding when the res is not mod16.

Comatose
4th September 2008, 16:56
And x264 always signals... if they don't crop, then they aren't standards compliant, right?

Sharktooth
4th September 2008, 17:12
dunno exactly how it works, maybe dark_shikari or akupenguin can explain things a bit better.
the only thing that is sure it's 1080p gets played back by DXVA hardware coz it's 1920x1088 (mod16)... and it gets cropped during decoding/playback to 1920x1080

ajp_anton
4th September 2008, 17:52
But by that logic, 640x360 gets played back by DXVA because it's 640x368 (mod16) and gets cropped during decoding/playback to 640x360.
So is the requirement mod4 then? Would make sense because with mod2 and YV12, the chroma channels have uneven resolutions.
On the other hand... I can see why decoding arbitrary resolutions can be problematic, but cropping uneven pixels shouldn't be a big deal...?

smok3
4th September 2008, 18:12
crop 10 pixels in height to get to 352 with zero error & all mod16,
http://resizecalc.somestuff.org/index.php?ssmw=1280&sar=1&sar2=&ssmh=716&CT=4&CL=&CR=&CB=8&mplayCrop=&trw=640&dar=1&dar2=&mod=&padw=&padh=&css=&doit=true

Sharktooth
4th September 2008, 18:31
But by that logic, 640x360 gets played back by DXVA because it's 640x368 (mod16) and gets cropped during decoding/playback to 640x360.
So is the requirement mod4 then? Would make sense because with mod2 and YV12, the chroma channels have uneven resolutions.
On the other hand... I can see why decoding arbitrary resolutions can be problematic, but cropping uneven pixels shouldn't be a big deal...?
nope. i said, i dont know how it works exactly. i only know 1080p is in reality 1920x1088 and DXVA decoders have no problems playing it back as it is mod 16.

ajp_anton
4th September 2008, 18:46
I *think* I know how it works (getting it confirmed from time to time but then I always find another group of people who says otherwise...): It is impossible to create non-mod16 (h264-) streams. If it appears to be something else, it's still mod16, just with borders cropped.
Since all decoders supports mod16 (duh), the only compatibility problem is in the amount of pixels cropped. Since 1080p works, then 8 pixels works. So the question is if mod4 (4 and 12 pixels cropped) or even mod2 works.

Comatose
5th September 2008, 13:49
Basically, any resolution will work as it is padded. Worst case scenario the decoder doesn't crop and you see the padding in playback.

foxyshadis
8th September 2008, 12:36
Well, the native source for the capture is 1280x720, but I always crop to visible pixels, which in this case was 1280x718.
However, my understanding was that mod4 is always better then mod2, so I cropped the extra two pixels.

You'd have been better off leaving the two extra pixels, unless you have actual playback problems with mod-2. Sharktooth is entirely incorrect with his insistence that only 1080 works with DXVA; all resolutions work just fine in all tests I've seen, though some decoders do have an actual mod-4 minimum, and the developers have gone over the way this works many times. However, some are much more strict on mod-16 width, since hardware makers won't give any concession unless it's forced out of them by specs.

Sharktooth
8th September 2008, 12:51
re-reading what i said, i'd say i was not clear (anyways all my replies are correct except one which may be misinterpreted... im going to edit it). DXVA has no restrictions. as i said in other thread, it depends on the decoders and actually some DXVA decoders are not able to decode non mod16 resolutions.