This is what I use if I have a similar problem, basically it uses an avs script to cut out the bad frames and keep the audio in sync.
I do not take credit for writing this, I copied it from a post I saw here and now I cant remember who posted it, if they see this Thanks.
Here is the original script
Code:
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\MPEG2Dec\MPEG2DEC2.dll")
#
# ------ avi File Number 1 ------
video=avisource("D:\Temp\movie01.avi")
audio=WAVSource("D:\Temp\audio01.wav")
#
# ------ Remove A/V Frames in File 1 ------
part1=trim(AudioDub(video,audio),0,12620)
part2=trim(AudioDub(video,audio),15575,21844)
part3=trim(AudioDub(video,audio),30009,62366)
part4=trim(AudioDub(video,audio),63509,0)
clip1=part1+part2+part3+part4
#
# ------ avi File Number 2 ------
video2=avisource("D:\Temp\movie02.avi")
audio2=WAVSource("D:\Temp\audio02.wav")
clip2=AudioDub(video2,audio2)
#
# ------ avi File Number 3 ------
video3=avisource("D:\Temp\movie03.avi")
audio3=WAVSource("D:\Temp\audio03.wav")
clip3=AudioDub(video3,audio3)
#
# ------ avi File Number 4 ------
video4=avisource("D:\Temp\movie04.avi")
audio4=WAVSource("D:\Temp\audio04.wav")
clip4=AudioDub(video4,audio4)
#
# ------ Join All avi Files ------
unalignedsplice(clip1,clip2,clip3,clip4)
#
# ------ Resize ------
LegalClip()
Grip(704,480,overscan=1)
GripSize()
TemporalSmoother(2,2)
GripBorders()
LegalClip()
The wav file are used to keep it in sync with video when using Trim
to remove frames. I use this with Tmpgenc to encode audio and video.
And here is a copy of a more simplified version I used recently
Code:
LoadPlugin("C:\Program Files\AviSynth2\plugins\MPEG2DEC.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\fluxsmooth.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\blockbuster.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\legalclip.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\GripFit_preview.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\Sampler.dll")
video=Mpeg2Source("D:\encode\movie.d2v")
audio=WAVsource("D:\encode\movie.wav")
part1=trim(AudioDub(video,audio),0,45113)
part2=trim(AudioDub(video,audio),45122,0)
unalignedsplice(part1,part2)
LegalClip()
GripCrop(352, 288, source_anamorphic=false)
GripSize(resizer="BilinearResize")
FluxSmooth()
BlockBuster(method="noise")
GripBorders()
LegalClip()
#Sampler(length=24)
I was getting divide by zero errors in Tmpg and this was the only way I could get around it after trying everything else.
Hope this helps.