Log in

View Full Version : Properly cropping padded 720p/1080i ?


Tio
25th April 2005, 07:32
Seeking advice on the proper cropping of LF & RT padding from 4x3 material (TS) captured at 1080i or 720p.

I have two scenarios that need attention. One is cropping for encoding to Full-D1 specs (pre resize/overscan filtering). The second would be cropping for PC viewing (960x720). I assume that the crop required would be the same for both prior to resizing.

I might also ask, this 4x3 material padded so that it may be displayed properly on 16x9 screens...is it 720x480 material upscaled and padded to fit? If so, what would be the max resolution before interpolation occeres thus reducing image quality?

-Tio

Tio
27th April 2005, 19:43
OK, how about I rephrase? ;-)

I am looking to crop, prior to resizing, TS material captured in either 1080i or 720p in preparation for encode to DVD or AVI. It is originally 4x3 aspect ratio with the L&R padding added bringing it to HD specs. My problem is figuring how much to crop before resizing due to the fact that by simply removing, for example, a total of 560 total from either side (of a 1280x740p ar) leaves me with a fair amount of actual image being removed. To compound this a couple of OTA stations use less padding and stretch the image horizontally by about 20%-25%.

Any insight would be greatly appreciated.

-Tio

midnightsun
29th April 2005, 03:10
If the material is indeed 4:3 then the active portion of the picture will be [(4/3)*720]x720, i.e. 960x720. This said, you have to crop a total amount of 320 pixels (it may be that it's not 160left/160right, the picture may not be exactly centered, you will have to check this), then simply resize to dvd resolution (720x480), remembering to set the display flag within the mpeg encoder to 4:3.

As general advice, when you have to resize a picture containing black bars that you want to remove, you first crop the black so that the cropped picture will have the desired (i.e. final) aspect ratio, then you resize to the output resolution.

Tio
29th April 2005, 23:56
Hmmmm, thanks midnightsun!

That calculation works a lot better with the 720p material. Reduces crop intrusion into the actual image and corrects the aspect ratio, both for DVD and 960x720 AVI's.

I'm figuring that for 1080i material the proper calculations would be [(4/3)*1080]x1080, i.e. 1440x1080.

Appreciate your insight and keeping me square! ;-)

-Tio

midnightsun
30th April 2005, 13:29
You're welcome ;)

Yes for 1920x1080i your math is correct; the only thing to be taken care of is that, since the material is interlaced, it's advisable to first separate the two fields, resize them and then weave them back together; something like:

separatefields, crop to 1440x540 (each field is half the height of the whole picture), resize to 720x240, weave. This of course if your output is dvd (interlaced). For avi you can leave the resolution at 1440x1080 or any 4:3 combination of (width)x(height). :)

scharfis_brain
30th April 2005, 14:57
separatefields()
crop()
resize()
weave()

is evil!
Especially with HD to SD conversions, because the video will bob up and down on TV (vertically misaligned fields)!

better use this script for interlaced HD to SD:


mpegsource("x.d2v")
crop(240,0,-240,-8) # crop to 1440x1080
leakkernelbob(order=1,threshold=6) # bob-deinterlace
converttoyuy2() # convert to yuy2 for proper chroma handling,
#YV12 is bad for reinterlacing!
lanczosresize(704,480) # downscale
assumetff() # use order=1 AND assume tff()
# or order=0 AND assumebff() depending on source
separatefields().selectevery(4,0,3).weave() #reinterlace

Tio
30th April 2005, 19:50
LOL, you guys are good! I was just preparing to ask the very question both of you are addressing as the encodes are not looking so well. All my IVTC encodes look fine it's just that dern interlaced material. My script (http://home.comcast.net/~mig317/temp/1088i-samp_script.txt) is very rudimentary (i.e. Kerneldeint only). Grrrrr!

I'm going to give the suggested filtering options above a go but in the meanwhile I have posted some raw TS samples if you would like to see what exactly it is I'm working with. Both have decent horiz/vert movement.

Sample #1 (11.3Mb/ 5 sec.) (http://home.comcast.net/~mig317/temp/1088i-samp.ts)
Sample #2 (7.5Mb/ 3 sec.) (http://home.comcast.net/~mig317/temp/1088i-samp2.ts)

My target encode is 640x480(or larger) avi for PC viewing and also 720/704x480 DVD.

Will let you know how your filter suggestions work.

Thanks!

midnightsun
30th April 2005, 20:24
thanks Scharfis for correcting. I didn't consider the downresize issue.

Tio
30th April 2005, 23:58
OK, now I'm thoroughly frustrated. I have scripted myself out of sanity! It seems nothing I script will give satisfactory results with this HD material (samples above) when encoded to DVD or PC-AVI specs.

ATSC, Interlaced, TFF.
DGDecode: Detect Pids & set, Field Op=none, YUV-RGB= PCScale.
AviSynth: 2.56, build: Sep 28, 2004
VirtualDub 1.4.9.3/CCE-SP 1.50.01
Athlon XP

Most recent script for DVD prep:
LoadPlugin("I:\AviSynth_Scripts\DGDecode.dll")
LoadPlugin("I:\AviSynth_Scripts\filters_&_docs\LeakKernelDeint.dll")
video=MPEG2Source("E:\~HD\alicia_witt-last_call_with_carson_daly_04-23-2005.d2v")
audio=DirectShowSource("E:\~HD\alicia_witt-last_call_with_carson_daly_04-23-2005.ac3")
audio = audio.Amplify(12)
audio = audio.DelayAudio(-0.459)
AudioDub(video,audio)
crop(240,0,-240,-8)
leakkernelbob(order=1,threshold=6,forceCPU=2)
converttoyuy2()
lanczosresize(672,448) # (also tried 704x480 w/o addborders)
addborders(16,16,16,16)
assumetff()
separatefields().selectevery(4,0,3).weave()
Trim(0,0)

Most recent script for PC-AVI prep:
Too convoluted now to even post. <G>


Any insight on getting this HD material to final encode properly would be greatly appreciated as I'm sure I must be missing something very elementary.

Best Regards,
-Tio