Log in

View Full Version : AviSynth with Audio and Decimate


TMLewiss2
22nd October 2004, 10:33
Ok, I am encodeing TV rips (SciFi Channel things) and I mostly use VirtualDubMod, AviSynth, DVD2AVI and BeSweet. My problem is that I don't know how to use audio in AviSynth, maybe I am going about this all wrong but here is what I am doing.


LoadPlugin("C:\Program Files\AviSynth2\plugins\decomb521.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\MPEG2Dec3.dll")
Mpeg2Source("C:\My Videos\Projects\Farscape.d2v",cpu=4,iPP=true)
telecide(1)
decimate(cycle=5, quality=3)
blur(1)
sharpen(.4)
TemporalSoften(4,4,8,15,2)
saturation = 1
cu = - (1-saturation)*256
ColorYUV(off_y=-9, gain_y=0, cont_u=cu, cont_v = cu, opt="coring")
Crop(8,60,-8,-60)
ConvertToRGB32()
Trim(13706,22274) ++ Trim(27717,43376) ++ Trim(47956,60254)
++ Trim(64826,74448) ++ Trim(79529,92149) ++ Trim(96985,98773)


Now that comes out to pretty good quality, but no audio at all. I know I can add the audio via "streams" in VirtualDubMod, but then it won't be trimmed to the right spots. I really don't want to convert it to an avi first. So what do I do? Oh yeah one other questions, if Decimate (Decomb Plugin) goes by every X frames, if I trim the movie wouldn't that make it remove the wrong frames? Anyways, feel free to improve script and thanks in advance for any help on this topic.

P.S.: Sorry if this is in the wrong spot, it contains audio and digital TV capture, so I didn't know where to put it.

fccHandler
22nd October 2004, 18:05
Your source is a .d2v file. It doesn't have audio.

I can think of two ways to go about it. You could add the line "AudioDub(last,WavSource("myaudio.wav"))" immediately before the "Trim" lines. Or if that doesn't work, you could remove the Trims from the Avisynth file, open it in VirtualDubMod, import the audio stream, and then trim it within VirtualDubMod.

if Decimate (Decomb Plugin) goes by every X frames, if I trim the movie wouldn't that make it remove the wrong frames?
I don't think so. Nevertheless I think it's best to do any trimming after Decimate has done its job.

TMLewiss2
22nd October 2004, 21:43
Yeah the problem is that doing trim in VDub takes forever after you use AviSynth. I will try the wav thing, I will have to demux it from the original, wish that more things suported AC3 though.

fccHandler
23rd October 2004, 04:51
I think there are ways to import AC-3 into Avisynth, but you can't edit AC-3 audio directly. (Well, you probably can, but it's likely to introduce all kinds of synchronization problems.) You're much better off working with the decompressed PCM audio.

TMLewiss2
23rd October 2004, 05:04
OK now this is just nasty, If I do the audio right before the trim it doesn't even encode. Even if it did, sice the frame numbers are dif after decimate it would trim the audio all wrong. I am stuck here, I have no clue what to. The same problem stands even if I do something like add the wav in "streams" in VDub and then manually trim.

TMLewiss2
28th October 2004, 04:51
Ok to understand the problem i think I will have to take you through some steps.

1. I record a TV show with my PVR 250 (So it is in MPEG format)
2. I use DVD2AVI to convert it to a dv2 or whatever.
3. I create a AviSynth Script useing MPEG2Dec3 and Decomb
4. It loads the video, telecides and then decimates(cycle=5)
5. Now remember the video is converted now to 23.97 from 29.97 fps.
6. The Audio is still 29.97 fps but it is the same cycle or whatever so it is still in sync.
7. Now here is where the problem comes in, I trim the video to remove the commercials. The audio it trimed at a different part since it has different frame rate. So it is all screwed up.

So the only think I can think of doing is trimming before the decimate. So i guess the question is how exactly does decimate work? Does it remove every 5th frame, or does it actually know what frames to remove. Because decimate is made to remove the extra frames that are pointless, and if you trim the video and it just does every 5th frame it will deleted the wrong frames after the trim right? Thanks in advance for anyone who can help me in any way.

ObiKenobi
28th October 2004, 14:29
You can just import the audio into the avisynth script using DirectShowSource along with the video and when it trims it should trim the audio segment as well.

Wilbert
28th October 2004, 14:43
He probably clicked on new thread instead of reply. I merged the threads.


This AC3Source downmixes incorrectly. Don't use it. If you have to import AC3, look at the docs of DirectShowSource.