View Full Version : Resizing DV 720X480 Interlaced to 352x480 Interlaced
dvdRENEGADE
29th April 2006, 10:52
I'm capturing video from my DV camcorder via firewire into DV format, 720x480 interlaced. I want to encode to 352x480 MPEG 2 with CCE and preserve interlacing. I use convolution3d denoise filter with avisynth. My script, without resizing, is:
LoadPlugin("Convolution3d.dll")
avisource("capture.avi")
SeparateFields()
odd=SelectOdd.Convolution3D(1, 32, 128, 8, 32, 10, 0)
evn=SelectEven.Convolution3D(1, 32, 128, 8, 32, 10, 0)
Interleave(evn,odd)
Weave()
ConvertToYUY2(interlaced=true)
What is the best way to resize using Avisynth filters and where should I place the resize filter into my script?
Thanks for any help, dvdRENEGADE
scharfis_brain
29th April 2006, 11:06
crop(8,0,-8,0).horizontalreduceby2()
is fully sufficient for horizontal only resizing and also preserves interlacing.
But you should go for some more advanced denoising filters.
dvdRENEGADE
29th April 2006, 12:27
Thanks for the info, but I don't really want to go that route. The quality wouldn't be quite as good and the aspect ratio would be slightly off, as well, correct? I'm thinking maybe going with BilinearResize. I'm needing to know if there's a better way of preserving interlacing while resizing and if my script looks correct for resizing to 352x480 interlaced? Time is not an issue, only quality. dvdRENEGADE
LoadPlugin("Convolution3d.dll")
avisource("capture.avi")
SeparateFields()
odd=SelectOdd.Convolution3D(1, 32, 128, 8, 32, 10, 0).BilinearResize(352,240)
evn=SelectEven.Convolution3D(1, 32, 128, 8, 32, 10, 0).BilinearResize(352,240)
Interleave(evn,odd)
Weave()
ConvertToYUY2(interlaced=true)
iantri
30th April 2006, 02:28
No, in fact what scharfis_brain is providing provides the /correct/ aspect ratio and simply resizing from 720 to 352 does not. Its all ridiculously complicated, but suffice it to say that the active image area (to be displayed in the 4:3 area of a TV image) is actually the middle 704 pixels. Hence, you need to crop 8 pixels off the left and right to resize.
As to "The quality wouldn't be quite as good", are you referring to his use of "HorizontalResizeBy2" instead of "BilinearResize"?
352 is exactly half of 704, so the math is pretty simple -- you simply need to take every other pixel. I suspect doing a Bilinear resize is just going to blur things slightly. YMMV.
Always resize last, as your filters should have as much data as possible to work on. So, do this:
LoadPlugin("Convolution3d.dll")
avisource("capture.avi")
SeparateFields()
odd=SelectOdd.Convolution3D(1, 32, 128, 8, 32, 10, 0)
evn=SelectEven.Convolution3D(1, 32, 128, 8, 32, 10, 0)
Interleave(evn,odd)
Weave()
HorizontalReduceBy2()
crop(8,0,-8,0).horizontalreduceby2()
ConvertToYUY2(interlaced=true)
Mug Funky
1st May 2006, 07:02
horizontalreduceby2 is a little sharper (not aliased though).
there seems to be a half-pel shift between this and the bilinear filter. probably because bilinear doesn't shift the image, wheras reduceby2 just takes x1 and x2 and averages them together (resulting in a half-pel shift of the image).
there's a speed advantage to reduceby2, and the quality doesn't suffer, so you might as well use it :)
foxyshadis
1st May 2006, 08:11
The halfpel shift has been part of avisynth since the very beginning, unfortunately. >.> Only matters if you're going to resize more than once though (like, say, any half-useful script function).
Mug Funky
1st May 2006, 09:20
well, it does make sense for it to shift by half a pixel - isn't it just averaging adjacent pairs of pixels? that's how i'd do it :)
dvdRENEGADE
2nd May 2006, 08:38
Thanks for the information everyone. So, my script should look like the following?
LoadPlugin("Convolution3d.dll")
avisource("capture.avi")
SeparateFields()
odd=SelectOdd.Convolution3D(0, 32, 128, 8, 32, 10, 0)
evn=SelectEven.Convolution3D(0, 32, 128, 8, 32, 10, 0)
Interleave(evn,odd)
Weave()
crop(8,0,-8,0).horizontalreduceby2()
ConvertToYUY2(interlaced=true)
@scharfis_brain
I've spent a few nights searching and reading thread after thread about denoising filters. They've apparently progressed rapidly within the last 3 yrs. or so and what was recommended in one thread has since become obsolete and something else becomes better. Plus, throw in all the differing opinions as they progress over the months and you get alot of confusion. What denoising filters do you recommend at this time? I mostly convert tv captures from picvideo mjpeg to cce mpeg2 and the occasional DV home video. Thanks, dvdRENEGADE
Mug Funky
2nd May 2006, 09:07
what's your target bitrate? i'm guessing below 3000kbps or so, otherwise you could go full D1 size.
because if the bitrate's at around 1500 or higher, you may be able to get away without denoising.
either way, i like to use:
fft3dfilter(bw=16,bh=16,ow=8,oh=8,bt=0,sigma=2.,plane=4)
change sigma to change the denoising strength. for analog TV you'd be looking at about sigma=2, but don't be afraid to go lower. it's a float number, so 1.5, 1.7 etc is possible.
the "bw,bh,ow,oh" parameters are just determining block size and overlap - i like them to fit the MPEG blocks, but i haven't tested to see if it's actually better that way :)
i think there's an interlaced mode for fft3d, so you could do away with the field-separating etc.
Similar discussion here
http://neuron2.net/board/viewtopic.php?p=6823#6823
http://neuron2.net/board/viewtopic.php?p=6851#6851
dvdRENEGADE
2nd May 2006, 22:38
@Mug Funky
Thanks. I'll try out fft3dfilter on some captures later tonight. I usually encode 352x480 between 2350-3200kb/s (3-4 hrs. per DVD-R).
@ariga
Thanks. That was a helpful link.
Serbianboss
3rd May 2006, 00:38
I mostly use Convolution 3d filter. And what i can say its very good filter. For me its better than most noise fiters. Degrainmedian is also good filter.
Mug Funky
3rd May 2006, 02:03
I usually encode 352x480 between 2350-3200kb/s
you probably wont need much or any filtering for half-D1 then.
try degrainmedian at default values - will boost compressibility a bit, remove a bit of noise and not hurt details. it's also a fair bit quicker than fft3dfilter....
dvdRENEGADE
3rd May 2006, 11:54
I tried the fft3dfilter and was very impressed with it. I tried it on some tv card captures and ,with a sigma=4, it removed the noise without notable blurring. I'll definitely be using it often. It was, as you said, slower than convolution3d. My encoding time doubled, but the quality was superb. I've still got to try the degrainmedian.
Serbianboss
3rd May 2006, 14:09
one question from me:
which parametars is good for low and for much noise(FFT3d) filter on vhs captures?
best regard
dvdRENEGADE
4th May 2006, 01:05
one question from me:
which parametars is good for low and for much noise(FFT3d) filter on vhs captures?
best regard
With my captures of a fairly noisy cable channel on my ATI tv card, I got a good result from this.
FFT3DFilter(sigma=4, interlaced=true)
Just change the sigma to whatever strength you need. If it's not interlaced, FFT3DFilter(sigma=4) or whatever strength you need would probably give you a good result.
Blue_MiSfit
4th May 2006, 01:32
If you've got a DirectX9 Video card that can run pixel shader 2.0 operations, try fft3dgpu, it uses your video card to run the denoise operation, which is VERY fast.
However, it may or may not support interlaced video. Don't take my word for it as I only deal with progressive. Try it out :D
~MiSfit
dvdRENEGADE
4th May 2006, 03:48
@Blue_MiSfit,
I tried the fft3dgpu. On my cheapo DirectX 9 card, EVGA FX5200, it crawled. It was MUCH slower than fft3dfilter. Of course, I had to convert colorspace, because it doesn't support YUY2. It doesn't support interlaced setting, so I had to separatefields and weave. With your setup, how much speed increase do you see with the fft3dgpu over the fft3dfilter?
dvdRENEGADE
4th May 2006, 05:19
I saved degrainmedian for last. With it, I've found the filter I'll use most for my TV captures. It was FAST and the quality was great. I knew when I was previewing my first test clip in VirtualDubMod and it was playing without stutter that it was gonna be very fast. Considering speed and quality, I'd say it's at the top of my list. 2-pass CCE encoding under realtime...that's cool. I'll probably still stick with Convolution3D for my cartoon captures. I like them to be more smooth. Thanks for all the recommendations. I'm very happy...YIPPEE!!!
Mug Funky
4th May 2006, 07:12
for VHS the hardest thing is getting past the time-base errors (which are not very noticable on playback, but severely degrade quality). these aren't exactly filter-outable, save for an ingenious but slow method that Clouded experimented with (i miss that guy...).
motion-compensated removedirt style filtering can trade off timebase errors for slight blurring, but this is a last resort because it can introduce more artefacting on moving objects (just tried this technique on some old, drab scottish TV series that came on Beta SP... stupid tape decks don't have the TBC card in them).
dvdRENEGADE
4th May 2006, 08:53
I started this thread asking about DV interlaced resizing and learned about that plus learned about some great denoising filters. Here's the final script I plan to use when resizing DV 720X480 to 352x480. I will use the DegrainMedian denoise filter 0.8 and resize the way Donald Graft had recommended for interlaced resizing in another thread, except for that he recommended LanczosResize instead of BilinearResize. Thanks again all, dvdRENEGADE
# The following line loads the DegrainMedian filter
#
LoadPlugin("DeGrainMedian.dll")
#
# The following line loads the video source.
#
Avisource("capture.avi")
#
# The following line denoises the video
# with the DegrainMedian filter.
#
DeGrainMedian(interlaced=true)
#
# The following 9 lines resize the
# interlaced video to 352x480 resolution.
# Donald Graft recommended this method.
# He used LanczosResize instead.
#
Global NewHeight=480
Global NewWidth=352
AssumeTFF()
SeparateFields()
Shift=(Height()/Float(NewHeight/2)-1.0)*0.25
Tf=SelectEven().BilinearResize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
Bf=SelectOdd().BilinearResize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
Interleave(Tf, Bf)
Weave()
#
# The above resizing is for top-field first video.
# To resize bottom-field first video replace the
# corresponding 4 lines above with these 4 lines.
#
# AssumeBFF()
# Tf=SelectOdd().BilinearResize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
# Bf=SelectEven().BilinearResize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
# Interleave(Bf, Tf)
Serbianboss
4th May 2006, 09:28
Because i use lot degrain median filter and convolution 3d, i would like to show 3 scripts which i have good results.
All scripts are for interlaced files(bottom field first)
script 1
SetMTMode(2)
LoadPlugin("DeGrainMedian.dll")
avisource("C:\Documents and Settings\capture\Video 1.avi")
ConvertToYuY2(interlaced=true)
degrainmedian(interlaced=true)
degrainmedian(interlaced=true)
crop(8,4,-8,-12)
AddBorders(8,8,8,8)
Script 2
SetMTMode(2)
LoadPlugin("DeGrainMedian.dll")
avisource("C:\Documents and Settings\capture\Video 1.avi")
ConvertToYuY2(interlaced=true)
degrainmedian(mode=1,limity=6,limituv=7,interlaced=true)
degrainmedian(mode=1,limity=6,limituv=7,interlaced=true)
crop(8,4,-8,-12)
AddBorders(8,8,8,8)
Script 3
SetMTMode(2)
LoadPlugin("Convolution3d.dll")
avisource("C:\Documents and Settings\capture\test1.avi")
ConvertToYuY2(interlaced=true)
SeparateFields()
odd=SelectOdd.Convolution3D (1, 32, 128, 16, 64, 10, 0)
evn=SelectEven.Convolution3D (1, 32, 128, 16, 64, 10, 0)
Interleave(evn,odd)
Weave()
crop(8,4,-8,-12)
AddBorders(8,8,8,8)
This scipts i use for bad vhs captures.
dvdRENEGADE
4th May 2006, 14:47
Oh yeah, in reference to the suggestions for the following method:
crop(8,0,-8,0).horizontalreduceby2()
I found a good explanation by jdobbs on the subject when someone asked him why he didn't implement it for his DVDRB with the 1/2 D1 option. I doubt he'd care if I shared it here.
He wrote:
"I'd like to point out that the statement "produces an ASPECT RATIO ERROR" is incorrect. If a picture is 4:3 OR 16:9 and is resized but again displayed as the same aspect ratio -- it is correctly done. You only have to reduce the size to 704xNNN if you plan to use the ReduceBy2 option. Also note that you will be removing 16 horizontal lines of data from the picture if you decide to do it the way you've noted, and you haven't truly reproduced the original picture... That's fine if the original has overscan areas, but not all originals do.
So if you are planning to use Bilinear, Bicubic, or Lanczos resizing do not use the crop() function or you actually will produce an incorrect aspect ratio."
Later in the same thread, he wrote some more:
"The picture is going to overscan whether you crop it or not. If you crop and then resize you will just be taking previously displayed portions of the picture and putting them in the overscan area. It is true that you could fix the incorrect aspect ratio caused by the crop and get the piece of video back by inserting black bars after the crop... but doesn't it make more sense to just not remove the overscanned video to begin with? It's kind of like digging a hole and refilling it..."
and he gave this suggestion for a test to prove it:
"Just a quick suggestion for anyone who really wishes to see what is the correct method for converting from 720xNNN to Half-D1.
1. Create a video that has a fixed square in the center of the screen.
2. Use a DVD-RW and create a 720x480 video.
3. Play it back and measure (using a ruler on your screen) the horizontal size of the original. Let's say it measures 10"
4. Do each of the suggested methods for Half-D1 conversion and put them (authored) as two choices on the same disc.
5. Run each and measure with a ruler. You'll find that the 10" measurement has been stretched to a little under 10.25" on an incorrectly converted video.
Now -- quite honestly -- you'd have to be an anal SOB with the eye of an eagle to be able to tell the difference when you're watching a movie, so I don't think it really matters... but it might be fun for someone with an inquiring mind and a little time on his/her hands who really wants to know."
I hope that's helpful to someone, dvdRENEGADE
hanfrunz
4th May 2006, 22:19
(just tried this technique on some old, drab scottish TV series that came on Beta SP... stupid tape decks don't have the TBC card in them).
@mug funky: try a digital betacam player (if there is one...)with analog playback: DVW-A510 or DVW-A500 (A=playes analogue tapes).
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.