PDA

View Full Version : Convert 4÷3 to 16÷9


bairradino
21st August 2003, 09:36
I have lots of interlaced DV PAL video in miniDV tapes, shooted at 4÷3 format, that I want to transfer to DVD's at 16÷9 format.
After reading and reading this forum (thanks to all for the information you share!) I made this simple script for the job.
My knowledge is limited so I decided to ask you some advices on:
1- The order of operations is correct?
2- Are these the best filters to use?
3- Do I get, with this method, the best possible quality?

script:
LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2()
SeparateFields()
LanczosResize(688,384) #"688" Because my TV streches the image horizontally
SelectEvery(2,1,0)
Weave()
Crop(0,96,-0,-96)
AddBorders(16,0,16,0)
Convolution3d(preset="movieHQ")

Thanks for help.
Bairradino

Kika
21st August 2003, 09:54
LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2()
SeparateFields()
LanczosResize(688,204,0,2,720,214).Weave()
AddBorders(16,84,16,84)
Convolution3d(preset="movieHQ")


Guess this Version is better, if your Source is PAL-DV-Video.

bairradino
21st August 2003, 10:45
Thanks Kika for your quick answer.
I tried your script in VirtualDubMod and it gives an error.
Mine above don't.
However, regarding your script, I don't see why the error.

Kika
21st August 2003, 11:37
Hm, why you are using VirtualDubMOD AND AVISynth? :confused:

OK, i never tried that. What an Error did you get?
Maybe it's this line:

LanczosResize(688,204,0,2,720,214).Weave()

Change it to:
LanczosResize(688,204,0,2,720,214)
Weave()

Wilbert
21st August 2003, 14:00
I don't know precisely what the problem is. But I see two errors in Kika's script:

LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2()
SeparateFields()
LanczosResize(688,204,0,2,720,214).Weave()
AddBorders(16,84,16,84)
Convolution3d(preset="movieHQ")

ConvertToYUY2 should be changed into ConvertToYUY2(interlaced=true). Both of you are applying Convolution3d to an interlaced stream, but you should apply it on a progressive stream. So change the script into:

AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2(interlaced=true)
SeparateFields()
clip = last.LanczosResize(688,204,0,2,720,214)
even = SelectEven(clip).Convolution3d(preset="movieHQ")
odd = SelectOdd(clip).Convolution3d(preset="movieHQ")
interleave(even,odd).weave()
AddBorders(16,84,16,84)

Kika
21st August 2003, 15:03
@Wilbert

I stand corrected. By myself, i don't use convolution3d, so i forgot the special usage for interlaced Source.

But is this:

even = SelectEven(clip).Convolution3d(preset="movieHQ")
odd = SelectOdd(clip).Convolution3d(preset="movieHQ")
interleave(even,odd).weave()

really necessary?
Shouldn't this script work too?

SeparateFields()
....
Convolution3d(preset="movieHQ")
Weave()

Wilbert
21st August 2003, 15:36
In that case you have to use a spatial smoother instead of a spatio-temporal one. The reason is that you are averaging multiple fields [I'm talking about the temporal averaging now] where two of them belong to the same original frame. That is not correct of course.

Remember the separate fields become frames (and thus resulting in a doubled framerate) when using SeparateFields.

Kika
21st August 2003, 16:07
The reason is that you are averaging multiple fields where two of them belong to the same original frame.

Now where you wrote that, it's absolutly clear (i've should known that...). :)

stickboy
21st August 2003, 17:51
You might want to check out my UnfoldFieldsVertical/FoldFieldsVertical (http://forum.doom9.org/showthread.php?s=&threadid=59029) functions, which can be useful for applying spatial-temporal smoothers to interlaced sources.

bairradino
22nd August 2003, 10:08
Hi guys,
I appreciate your comments and your will to help people like me.
However I didn't understand your calculations. Correct me if I'm wrong:

1- I start with an interlaced frame composed by two fields (bottom first) of 720x576 pixels.

2- ApplyingSeparateFields()
I transform that interlaced frame in two progressive frames of 720x288.

3- Applyingclip = last.LanczosResize(688,204,0,2,720,214) I'll crop 2 pixels on top and 72 pixels on bottom of each progressive frame, and then resize them to 688x204.

4- Applyinginterleave(even,odd).weave()
I'll have an interlaced frame of 688x408 but with less 4 pixels on top and 144 pixels on bottom, respect to the original frame (frame out of center).
As the effective frame for a 16÷9 format, before expand it, should be 720x432, I'll have a 4% distortion on horizontal (necessary for my TV) and almost 6% distortion on vertical wich will override the desired horizontal distortion.

5- If all my calculations are correct don't you think that should be better change the script to:

LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2(interlaced=true)
clip = last.LanczosResize(688,576,0,72,720,432)
SeparateFields()
even = SelectEven(clip).Convolution3d(preset="movieHQ")
odd = SelectOdd(clip).Convolution3d(preset="movieHQ")
interleave(even,odd).weave()
AddBorders(16,0,16,0)

Thanks for helping
Bairradino

Wilbert
22nd August 2003, 11:23
Your remarks are correct, I didn't check the resize parameters. Just copied them from Kika.

You should apply the resizing after separatefields (on a progressive stream).

Anyway, checked the calculations with FitCD. I assumed that your image is 720x432 (after cropping black borders, please say so if this is false). You also want to include overscan in your final format. The final script should be:

1) in case your source is progressive:

LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2()
LanczosResize(688, 544, 0, 76, 720, 428)
Convolution3d(preset="movieHQ")
AddBorders(16,16,16,16)

2) interlaced source, like you have:

LoadPlugin("C:\Programs\Avisynth 2.5\Plugins\Convolution3D.dll")
AVISource("C:\temp\exp.avi") #PAL DV 4÷3 format
ConvertToYUY2(interlaced=true)
SeparateFields()
LanczosResize(688, 272, 0, 76, 720, 214) # 544/2 = 272 and 428/2 = 214
even = SelectEven(clip).Convolution3d(preset="movieHQ")
odd = SelectOdd(clip).Convolution3d(preset="movieHQ")
interleave(even,odd)
weave()
AddBorders(16,16,16,16)

I hope it's clear now :)

Kika
22nd August 2003, 13:07
Oops, that was my fault. I've set the Resizing for 1.85:1, not for 16:9...

bairradino
22nd August 2003, 13:11
Wilbert,

My inicial footage is 720x576 in 4÷3 format (wich has a pixel aspect ratio of 768/720=1,06667).
As I want to transform to 16÷9 format (wich has a pixel aspect ratio 0f 1024/720=1,42222) I must crop vertically the image by 72 pixels both top and bottom of the image in a way of getting 720x432.
Then I must resize the image vertically to get again 720x576 getting an image that is streched when viewed on a monitor. However when viewed in a TV or Authored to DVD this image gets the correct pixel aspect ratio of 1,42222.
Of course in this proccess I lost information of both original top and bottom 72 lines of pixels.
Apart to this calculations I must introduce an horizontal correction to my TV's horizontal deformation (that's the reason for resizing to 688).
I hope you can understand my explanation... because English is not my native language. I'm Portuguese.

Kika
22nd August 2003, 14:19
OK, to correct my fault from before:

You have footage with 4:3 and want it to be 16:9. So you must crop the Video.
The PAR of DV isn't 1.0667, it is 1.092. 720x576 is the same than 786x576 in square Pixels (768x576 square Pixels are 704x576 non Square)

You have two choices:
Crop to 704x432, Letterbox to 704x576
Crop to 704x442, Resize to 704x432, Letterbox to 720x576

Both of them will give you an AR of 1.78:1 and both of them are valid DVD-Resolutions.

If you need an Overscan-Correction, then there are also two ways:
Crop to 672x416, Letterbox to 704x576
Crop to 704x442, Resize to 688x424, Lettbox to 720x576


(BTW: This time, i've checked it with Fit2Disc before posting it ;) )

bairradino
22nd August 2003, 15:08
Kika,

I'm sorry to disagree with you. The PAR of 4÷3 DV is realy 1,06667(768x576 square to 720x576 non square -> 768/720=1,06667) because the DV PAL norm indicates that the resolution of video is 720x576 (not 704x576).
Any Adobe video software says the same and if you want to incorporate a still image in your video you must create it with 768x576 and then stretch it to 720x576 before importing it to your video editing software.
The same is true for 16÷9 format but the values are diferent: 1024x576 square pixels to 720x576 non square.
I made some proves with 720x576 4÷3 shooted video, then 1) cropped to 720x432 or 2) resized to 720x768 and cropped to 720x576 and both locked perfect on my 16÷9 TV (by the way I never mentioned that my movies will be watched in such a TV format).
The problem with my Avisynth script is when I want to filter.
The Letterbox is applied automatically by DVD player depending the format it is configured.
Some people use to eliminate the borders of image because, according them, there are some distorted video information on that areas.
By the way, Kika, the reason Why I use VirtualDubMod is only for previewing the results of the Avisynth script.

Kika
22nd August 2003, 15:21
@bairradino

I know all of this, but it is wrong. And the way to prove this, is very old.
The ITU-Specs are absolutly clear about DAR and PAR - there is no PAR of 1.0667!
Full-D1 PAL is defined as 720x576 with a PAR of 1.092 and an active Pixel-Area of 704x576. That's why this Resolution is still Part of the DVD-Specs.
I wrote it in an other Thread: Try it by yourself.
Draw a Circle of 576x576. Put it into a Pic of 768x576 and resize it to 720x576 and encode the Video. After that, the Circle isn't an exact Circle anymore.
Take the same Circle an put it into a Pic of 786x576. Resize it to 720x576. You will get a perfect Circle in your Video.
Again, take the Circle and put it into a Pic of 768x576. Resize it to 704x576. Again, you will get a perfect Circle in the resulting Video.

(I don't know what happend the last years here. But in the early years of Doom9 this was a well known knowledge.)

Maybe this helps to understand PAR and DAR better:

http://toolbox.sgi.com/TasteOfDT/documents/video/lurker/pixelaspect.html

http://www.uwasa.fi/~f76998/video/conversion/

bairradino
22nd August 2003, 15:51
Kika,

Thanks for your efforts.
I give you some credit and I'll make other tests.
Possibly you're right and I had been living in error for some time ago.
However I can assure you that if you use Adobe Premiere or After Effects you will see the PAR reported by Adobe as beeing 1,067 or 1,422.
My TV is not as plane iy should be in order to take correct measures. However I'll made some tests exporting a still image from the video, streched to 768x576, and I'll measure it in Photoshop.
The important thing is not who's right or wrong but the truth.
I'll give a reading in your links.

Kika
22nd August 2003, 16:58
My TV is not as plane iy should be in order to take correct measures.

Most of TVs do have this problem. I've adjusted mine by using the Service-Menu and an Signal-Generator. Be default, the Picture was anything, but not 4:3. ;)
Now, the visible Area is nearly exact 4:3 by a Pixel Area of 672x544.


The important thing is not who's right or wrong but the truth.

Right.

I'll give a reading in your links.

Yeah, they are very intersting. The first time, i stumbled over this 720x576 Resolution, i was a bit confused too. Than i've found an discussion here on Doom9 about that (years ago), later the Sites i linked. And i did (and not me only) some tests by myself - and i got the complete Specs of MPEG2 and DVD. The result: There are only two true PAL 4:3-Resolutions:
704x576
720x576 with an active Area of 704x576

bairradino
26th August 2003, 08:27
Kika,

You're right!
The only way of getting a non distorted image is stretching a 768x576 image (4÷3 square pixel) to 704x576, wich means that PAR is 768/704=1,0909.
The time I spent reading the wrong explanations...

Bairradino

deXtoRious
26th August 2003, 12:47
I know this is slightly offtopic, but could anyone suggest a script that could resize a video from 1000x540 to 640x480 without getting a distorted image?

Kika
26th August 2003, 13:08
Strange format...

I don't know the source, but this may be nearly correct:
Resize it to 640x352 or to 640x346 (letterbox to 352 or 480)

deXtoRious
26th August 2003, 13:42
Yes, it is. The source is the Matrix Reloaded super-high quality trailer.
Thanx for the help, I'll try it now.

EDIT: Just tried it. The picture is fine. However when I click on file and check the resolution in properties it still shows 640x352. Is it ok? The script is as follows:
AviSource("trailer.avi")
LanczosResize(640,352)
Letterbox(64, 64)

Once again thanks for the help :)

Kika
26th August 2003, 14:20
when I click on file and check the resolution in properties it still shows 640x352. Is it ok?

Yes, that's OK. The Source has the AR of 1.85:1, the Destination... um, is a bit distorted because of the Mod16-Rule. 640x346 is the better Resoltion, but needs Borders. The 640x352-Resolution don't need any Borders.

Oh, i see, you used Letterbox instead of AddBorders. Try this:

AviSource("trailer.avi")
LanczosResize(640,346)
AddBorders(0,67,0,67)

To get 640x480. But, like i said, that's not necessary on AVIs. You can do it this way:

AviSource("trailer.avi")
LanczosResize(640,346)
AddBorders(0,3,0,3)

deXtoRious
26th August 2003, 14:35
Oh, i see, you used Letterbox instead of AddBorders. Try this:
AviSource("trailer.avi")
LanczosResize(640,346)
AddBorders(0,67,0,67)

Thanx, that works simply perfect!!

You can do it this way:
AviSource("trailer.avi")
LanczosResize(640,346)
AddBorders(0,3,0,3)

That would just create a 640x352 video, right?

Kika
26th August 2003, 14:44
Genau! ...um..., Right! ;)

deXtoRious
26th August 2003, 15:13
Please don't... I'm "learning" German in school. No offense, but your grammar is simply horrible :(

Kika
26th August 2003, 23:27
My english grammar? Yeah, i know it's horrible, but that isn't a new Message ;)

My german grammar? No, it's excellent... :p

deXtoRious
27th August 2003, 11:03
No, I meant the grammar of the German language. It's terribly hard.

Kika
27th August 2003, 12:24
Oh, i understand.

Yes, your right. The german grammar is a hard one - even a lot of germans do have their problems with it... ;) :cool:

OK, enough, it starts becoming a little off topic. :p

deXtoRious
27th August 2003, 17:29
Well, then I'll just ask another question ;)

How can I transform a NTSC DVD (720x480) to PAL DVD?

Kika
28th August 2003, 08:21
That depents on the Source. Is it interlaced (maybe from a TV-Show)? Is it true FILM, encodet with 3:2 Pulldown or with 3:2 Pulldown on Playback?
There are Guides and many discussions here on the Board about converting NTSC->PAL->NTSC.

deXtoRious
28th August 2003, 11:05
The source is a true FILM. I was unable to find any guides, so if you've seen any, please give me a link.

Kika
28th August 2003, 14:10
If it realy is true FILM (23.976 FpS) all you have to do is a proper Resizing and a PAL SpeedUp.

BicubicResize(720,576,0,0.6)
AssumeFPS(25.000, true)

But this gives you a pitched Audio-Part. In order to prevent this, you can use a WAVE-Editor to SpeedUp and pitch the Audio.

deXtoRious
28th August 2003, 14:20
And what if it only applies the pulldown during playback?

cweb
30th August 2003, 13:23
Originally posted by Kika
Hm, why you are using VirtualDubMOD AND AVISynth? :confused:


Hmm.. I always use Vdubmod and Avisynth - works like a charm.

TNM
31st August 2003, 16:19
I'm sorry to ask but can anyone pls tell me how to resize a 640x480 full-screen clip (I'm noob about all these aspect ratio so dunno how to describe it better) to 640x352 without distort or crop the image? Thanks in advance...

manono
31st August 2003, 18:42
Hi-

AddBorders(116,0,116,0)
LanczosResize(640,352)

is pretty close.

TNM
1st September 2003, 10:20
Originally posted by manono
Hi-

AddBorders(116,0,116,0)
LanczosResize(640,352)

is pretty close.

Thanks for your answer... The image is indeed not cropped or distorted but there're 2 huge vertical black borders... Is there a way to get rid of these and the image is still at 640x352?

Kika
1st September 2003, 10:32
I'm sorry to ask but can anyone pls tell me how to resize a 640x480 full-screen clip (I'm noob about all these aspect ratio so dunno how to describe it better) to 640x352 without distort or crop the image

Without these black bars it won't work. But why will you do suche Resizing? There's no reason for doing that.

TNM
1st September 2003, 10:50
Originally posted by Kika
Without these black bars it won't work. But why will you do suche Resizing? There's no reason for doing that.

Umm the idea is to convert to dvd 16:9 aspect ratio and make a smaller res, I'm hoping to reduce filesize by doing that. Sorry if it sounds stupid...

Kika
1st September 2003, 11:05
OK, the Point was, you wrote 640x480 full-screen. If it is 16:9, that's an other story. Just cut away the black borders at top and Bottom, take care about the MOD16-Rule. That's all.

TNM
1st September 2003, 16:34
Originally posted by Kika
OK, the Point was, you wrote 640x480 full-screen. If it is 16:9, that's an other story. Just cut away the black borders at top and Bottom, take care about the MOD16-Rule. That's all.

If it was like that I wouldn't bother you all :p By 640x480 full-screen I meant the picture covers all the screen, there arent any black borders...

manono
2nd September 2003, 02:21
Hi-

It's pointless to make a 16:9 DVD from a full-screen 1.33:1 movie. Just encode it as 4:3 and be done with it. Movies won't benefit from 16:9 encoding unless the movie AR is greater than about 1.55:1. That's halfway between 4:3 (1.33:1) and 16:9 (1.77:1). So, 1.66:1 movies will benefit a little bit, 1.85:1 movies more, and 2.35:1 movies a lot. 1.33:1 full-screen movies are actually hurt a bit from 16:9 encoding, and I have yet to see one on DVD that way.

Is there a way to get rid of these and the image is still at 640x352?

Not without cropping and/or distorting the picture.