Log in

View Full Version : Newbie Advice Needed - Deinterlacing DVDs


peridian
20th October 2012, 23:39
Hi,

This is probably yet another "I don't understand" thread, but I've been playing around with Avisynth for over a month now, and still have unanswered questions.

I've got a lot of DVDs I'd like to transcode to mp4 so I can stream them at home. Batch transcoding is the easy part, I wanted to see if I could use AviSynth to ensure I keep as cleaned up a version of the video as I can.

After a lot of Googling and trial and error, this is the script I have so far:


# Load required plugins.
loadplugin("F:\AviSynth\plugins\DGDecode.dll")
loadplugin("F:\AviSynth\plugins\NicAudio.dll")
loadplugin("F:\AviSynth\plugins\nnedi2.dll")
loadplugin("F:\AviSynth\plugins\mvtools2.dll")
loadplugin("F:\AviSynth\plugins\MT.dll")
loadplugin("F:\AviSynth\plugins\mt_masktools-25.dll")
loadplugin("F:\AviSynth\plugins\RemoveGrain.dll")
loadplugin("F:\AviSynth\plugins\Repair.dll")
loadplugin("F:\AviSynth\plugins\vertical cleaner\VerticalCleaner.dll")

# Import Deinterlacer
import("TempGaussMC_beta2.avsi")

# Function for re-use.
function Transcode(string dvdIndex,
\ string ac3Audio,
\ int trimFrames,
\ float audioDelay,
\ int cropLeft,
\ int cropTop,
\ int cropWidth,
\ int cropHeight,
\ bool isInterlaced,
\ int newWidth)
{
video = mpeg2Source(dvdIndex, cpu=0, info=3) # Get dv2 index file and ac3 audio output from DGIndex.
audio = nicAC3Source(ac3Audio)

video = Trim(video, trimFrames, 0) # Trim the start off the video as appropriate.

AudioDub(video, audio) # Combine audio with video.

DelayAudio(audioDelay - 0.1) # Delay the audio in order to keep in-sync.
# Adjusts by 100ms as AudioDub seems to introduce a slight delay.

ConvertToYV12(interlaced=isInterlaced) # Convert colour space.

Crop(cropLeft, cropTop, cropWidth, cropHeight) # Crop off unwanted black borders.

TempGaussMC_beta2(1, 1, 0, 0, 0, 0,
\ sharpness=0,
\ Smode=0,
\ SLmode=0,
\ Sbb=0,
\ SVthin=0.0,
\ EdiMode="NNEDI2") # Quick settings (approx: 10-12fps)

#TempGaussMC_beta2(tr2=3,
# \ sharpness=1.7,
# \ SLrad=2,
# \ Sbb=2,
# \ SVthin=0.75,
# \ Sovs=2,
# \ EdiMode="NNEDI2") # Slow settings (approx: 0.5 - 2fps)

SelectEven() # Select only half the frames from the above deinterlacing.
# Note: This causes audio sync issues.

ratio = float(width) / float(height) # Determine new video height to maintain aspect ratio.
newHeight = round(newWidth / ratio / 2) * 2

return Lanczos4Resize(newWidth, newHeight) # Upscale to new width, with appropriate height.
#return spline36resize(newWidth, newHeight)
#return nnedi2_rpow2(rfactor=2, cshift="spline36resize", fwidth=newWidth, fheight=newHeight)
#return nnedi2_rpow2(rfactor=2, cshift="Lanczos4Resize", fwidth=newWidth, fheight=newHeight)
}

#################
## Do the work ##
#################

mpegIndex = "H:\Andromeda\Andromeda.d2v"
ac3File = "H:\Andromeda\Andromeda AC3 T01 2_0ch 192Kbps DELAY -19ms.ac3"

Transcode(mpegIndex, ac3File, 206, -0.019, 6, 2, -6, -2, true, 1024)



The questions I have are:

I cannot see any difference/impact between AssumeBFF and AssumeTFF. Do these even apply to DVD vob files?

When I don't use SelectEven, the video is at 50fps and the audio is perfect, but when I do use SelectEven, the video is at 25fps and the audio seems to be ever so slightly out of sync. I would prefer the 25fps video, but how do I ensure that the audio remains in sync?

I cannot see any difference in the use of the interlaced flag on ConvertToYV12, it certainly doesn't prompt any deinterlacing by itself. Do I even need to use this?

I cannot see any difference between the Lanczos4 and spline36 resize options, and some articles seem to suggest there isn't any. Is there?

A lot of people seem to think using the nnedi2 version of the resize functions is better, but I cannot see any difference and the nnedi2 version takes far longer to process. Is there any point in using it?

A lot of people seem to think TGMC is very good. While I have used the really high quality settings to see a significant improvement in some videos, the sheer additional processing time just is not worth it imo. Is there a simple alternative that would deliver good quality deinterlacing / cleanup but without masses of extra processing time?

Would appreciate any advice or help with this, as I would like to start batch processing these DVDs sooner rather than later.

Regards,
Rob.

Guest
21st October 2012, 00:07
I cannot see any difference/impact between AssumeBFF and AssumeTFF. Do these even apply to DVD vob files? Since neither appears in your script I suppose it doesn't matter. :)

They are used to force a field order for following filters that may care about field order. mpeg2source() sets it correctly so there's no need to force anything.

When I don't use SelectEven, the video is at 50fps and the audio is perfect, but when I do use SelectEven, the video is at 25fps and the audio seems to be ever so slightly out of sync. I would prefer the 25fps video, but how do I ensure that the audio remains in sync?

That shouldn't happen. Are you sure you are not imagining it? If it is real you can adjust for it with DelayAudio().

I cannot see any difference in the use of the interlaced flag on ConvertToYV12, it certainly doesn't prompt any deinterlacing by itself. Do I even need to use this? It's already YV12 out of mpeg2source(), so you can omit that.

I cannot see any difference between the Lanczos4 and spline36 resize options, and some articles seem to suggest there isn't any. Is there? Mathematically, obviously yes. Whether the difference is perceptible to you or not, well, you can decide.

A lot of people seem to think using the nnedi2 version of the resize functions is better, but I cannot see any difference and the nnedi2 version takes far longer to process. Is there any point in using it? Certainly not, if you can see no difference.

A lot of people seem to think TGMC is very good. While I have used the really high quality settings to see a significant improvement in some videos, the sheer additional processing time just is not worth it imo. Is there a simple alternative that would deliver good quality deinterlacing / cleanup but without masses of extra processing time? You get what you pay for, time-wise. You can try yadif to tradeoff some quality for time.

lansing
21st October 2012, 01:44
with 50fps you'll get a smoother video than 25fps, and the file size will only be slight bigger, so it would be a good tradeoff imo.

and don't forget to use multithread avisynth if you have a multicore processor, it'll make a huge difference in speed. I've tested on an i7 3610QM laptop a few days ago using QTGMC(preset = "slower") on a dvd source, and i'm getting 50+fps on avsmeter

peridian
22nd October 2012, 17:31
Thanks for the tips. I must be using a single threaded version, so I will try to replace it with the multithreaded version. Hopefully that will make things more acceptable.

RE: Audio sync, I'm definitely not imagining it (coz that's what I thought originally, and I spent ages trying to figure out if I was losing my mind). I'm not sure if it's to do with the removal of frames from the video, but I thought it would correct the audio as well.

Will try some more variations.

Regards,
Rob.