Log in

View Full Version : 720x480 to 853x480 Anamorphic Resize


Seraphic-
3rd June 2008, 02:50
Hi,

I have a 480p video at 720x480 and I wanted to resize to 853x480. Could anyone offer some recomendations and some code samples on methods to achieve a high quility resize (I'll crop down to mod 16)?

(I'll post a sample video in a bit)

Thanks

Blue_MiSfit
3rd June 2008, 03:30
Well, if you must resize before encoding, that's the way to do it :)


lanczosresize(853,480) #Lanczos is the standard around here
spline36resize(853,480) #Spline36 is another favorite
# you get the picture, it's simple :)

Seraphic-
3rd June 2008, 03:49
Hi,

Yeah, I need to do the resize before playback/encoding.
The reason is that I need to add overlay layers to the video, so it is easier to be able to have everything the same size.

Here are some samples I tried on my own and a five second sample of the video.
Overall, it looks alright. But wasn't sure if I was doing it the most optimal way as the process somewhat blurred the video.

Thanks, I'll give those a try and see how it goes.
Are there any configuration parameters with those or is that all that is needed?
Also, what is the difference between Lanczos4Resize, Lanczos3Resize, and lanczosresize?

Five second raw sample at 720x480 (http://www.temp.seraphicgate.com/720480p.rar)

http://www.temp.seraphicgate.com/720480p.png
http://www.temp.seraphicgate.com/853480p.png

Blue_MiSfit
3rd June 2008, 04:16
lanczos3resize=lanczosresize

lanczos4resize is a bit sharper, but can introduce ringing sometimes..

Seraphic-
3rd June 2008, 04:54
lanczos3resize=lanczosresize

lanczos4resize is a bit sharper, but can introduce ringing sometimes..

The video is YUY2 and it won't accept lanczosresize(853,480) as it requests even numbers.
I thought something like the below would fix it but doesn't. One pixel isn't a major deal though, so I'll have to use 852x480.

I'll see if I can search for some ways to sharpen up and maybe smooth some of the edges.

lanczosresize(853,480)
crop(1, 0, 0, 0)

cyberbeing
3rd June 2008, 06:19
I think that is a 4:3 anamorphic not a 16:9 (PS2 game?). The circle button isn't circular when resized to 16:9.

I would do something like this to crop off the black borders and then resize to MOD4:
http://img147.imageshack.us/img147/4013/640x480nd7.th.png (http://img147.imageshack.us/img147/4013/640x480nd7.png)

crop( 36, 16, -44, -18)
lanczos4resize(640,480)


or to keep it sharper
http://img145.imageshack.us/img145/4024/592x444fm4.th.png (http://img145.imageshack.us/img145/4024/592x444fm4.png)

crop( 36, 16, -44, -18)
spline36resize(592,444)

Seraphic-
3rd June 2008, 06:41
I think that is a 4:3 anamorphic not a 16:9 (PS2 game?). The circle button isn't circular when resized to 16:9.

I would do something like this to crop off the black borders and then resize to MOD4:
http://img147.imageshack.us/img147/4013/640x480nd7.th.png (http://img147.imageshack.us/img147/4013/640x480nd7.png)

crop( 36, 16, -44, -18)
lanczos4resize(640,480)


or to keep it sharper
http://img145.imageshack.us/img145/4024/592x444fm4.th.png (http://img145.imageshack.us/img145/4024/592x444fm4.png)

crop( 36, 16, -44, -18)
spline36resize(592,444)


Yes, it is a PS2 game. However, it was set to 480 Progressive mode with 16:9 aspect ratio.
So the system outputs it in 4:3, but horizontally squished, so it need to be resized to widescreen, or 853x480.
If it was set to 4:3, then no resizing would be needed.

Why use lanczos4resize? Blue_MiSfit said it can introduce ringing.

Don't understand what you mean by "resize to MOD4" :confused:
I was planning to crop to MOD16 for x264.

cyberbeing
3rd June 2008, 07:01
Being MOD4,MOD8,or MOD16 (height and width divisible by 4/8/16) will improve compressibility with MOD16 being the best. Lancos4Resize is sharper (ringing/haloing will improve sharpness but I doubt you would see anything noticeable for that small resize). Spline36Resize would be considered neutral and softer than Lancos4Resize. Since upsizing an image makes it softer anyways, having a sharper resizer can be helpful but it's all personal preference.

Well if that is the case you could do something like
http://img299.imageshack.us/img299/4351/848x480ho8.th.png (http://img299.imageshack.us/img299/4351/848x480ho8.png)

crop( 36, 16, -44, -18)
lanczos4resize(848,480)


or to keep it sharper
http://img145.imageshack.us/img145/1181/796x448nm7.th.png (http://img145.imageshack.us/img145/1181/796x448nm7.png)

crop( 36, 16, -44, -18)
lanczos4resize(796,448)


If you want to keep 16:9 exactly you could resize it to 704x396 or 960x540.

Seraphic-
3rd June 2008, 07:12
Being MOD4 (height and width divisible by 4) will improve compressibility. Lancos4Resize is sharper (ringing/haloing will improve sharpness but I doubt you would see anything noticeable for that small resize). Spline36Resize would be considered neutral and softer than Lancos4Resize. Since upsizing an image makes it softer anyways, having a sharper resizer can be helpful but it's all personal preference.

Well if that is the case you could do something like

crop( 36, 16, -44, -18)
lanczos4resize(796,448)


or

crop( 36, 16, -44, -18)
lanczos4resize(848,480)


Alright, I'll give those a try.
But if the size it is meant to be viewed at is 853x480 (852x480 nearest), wouldn't it be ideal to resize to that and then crop down?
Or was your point that the less you resize the sharper it remains? Like with "796,448".

I knew what MOD4 was, just didn't understand why you were suggesting it

cyberbeing
3rd June 2008, 07:35
Well the actual size rendered by the PS2 is 640x446 (which is the size after cropping the black bars off). 796x448 (or 800x448 for MOD16) stays close as possible to the original height. 848x480 or 960x540 are also MOD16 if you wanted it bigger and 704x396 or 640x360 if you wanted it smaller.

2Bdecided
3rd June 2008, 10:59
If you want sharp...
avisource("720480p.avi")

crop( 36, 16, -44, -18)
spline36resize(852,480)

limitedsharpenfaster(strength=150)


Or alternatively, to knock some of the jaggies off, try...
avisource("720480p.avi")

crop( 36, 16, -44, -18)
eedi2(mthresh = 50, lthresh = 200, vthresh = 200, dstr = 8).turnleft().eedi2(mthresh = 50, lthresh = 200, vthresh = 200, dstr = 8).turnright()
spline36resize(852,480)

limitedsharpenfaster(strength=200)

A single EEDI2 (or NNEDI) followed by a resize back down to what you want is sometimes a really nice way to expand anamorphic content while maintaining sharpness. Slow, but given that you throw half the faked resolution away again, artefacts are tiny.

Given that you want to inflate both directions here, two calls to EEDI2 can give more artefacts (or a specific "look"), so it's less ideal - and even slower. Depends what you want.

Cheers,
David.

Seraphic-
3rd June 2008, 17:34
Well the actual size rendered by the PS2 is 640x446 (which is the size after cropping the black bars off). 796x448 (or 800x448 for MOD16) stays close as possible to the original height. 848x480 or 960x540 are also MOD16 if you wanted it bigger and 704x396 or 640x360 if you wanted it smaller.

Yeah, I thought it wasn't using the full 480 height as well, but after trying a few other games, it seems it depends on the game.
Here is another game that uses the full height, but just for FVM videos. In this case, the FMVs are rendered at 638x478, but the gameplay is like the other game I posted here.
So I think it does proved 640x480, just depends on if the game uses it or not.

http://www.temp.seraphicgate.com/full46.png

If you want sharp...
avisource("720480p.avi")

crop( 36, 16, -44, -18)
spline36resize(852,480)

limitedsharpenfaster(strength=150)


Or alternatively, to knock some of the jaggies off, try...
avisource("720480p.avi")

crop( 36, 16, -44, -18)
eedi2(mthresh = 50, lthresh = 200, vthresh = 200, dstr = 8).turnleft().eedi2(mthresh = 50, lthresh = 200, vthresh = 200, dstr = 8).turnright()
spline36resize(852,480)

limitedsharpenfaster(strength=200)

A single EEDI2 (or NNEDI) followed by a resize back down to what you want is sometimes a really nice way to expand anamorphic content while maintaining sharpness. Slow, but given that you throw half the faked resolution away again, artefacts are tiny.

Given that you want to inflate both directions here, two calls to EEDI2 can give more artefacts (or a specific "look"), so it's less ideal - and even slower. Depends what you want.

Cheers,
David.

I guess what I was looking for was a sharp anamorphic resize to mimic what you would get if watching/playing on a TV.
Thanks for the code samples I'll give them a try.

This has been a PS2 played on a PS3 in progressive mode with hardware smoothing enabled. Although, I don't see much difference with it on.

http://www.temp.seraphicgate.com/ps.png

Also, here is the difference between 480p 4:3 (top) and 16:9 (bottom) Anamorphic. As you can see, the 16:9 is horizontally squished. It needs to go to 853x480 or the nearest.

http://www.temp.seraphicgate.com/720480p43.png
http://www.temp.seraphicgate.com/720480p.png