View Full Version : An ideal VCD to DivX AVS script
I've been stuffing around for ages to try and get a good method of being able to convert VCD's to single CD divx's. I've always had problems keeping a/v sync, especially when combining the two avi's (from each VCD part) back into one avi.
I've used all the guides on Doom9's pages but I am still not satisfied.
So after lots of stuffing around I've come up with an AVS script that allows me to manipulate each a/v stream and sort out any sync issues I might have for any particular VCD.
See Below. first of all this method requires a fair bit of HD space (about 4.5GB for a 2hour VCD). This is because I convert the video stream to MJPEG (Quality of 19) and the sound to raw PCM wav.
In the script below testxx.avi and testxx.wav are each VCD disk respectively.
(the AVIsource line is wrapped)
a=AVISource("d:\swep\test01.avi").Crop(0,34,352,172).BilinearResize(576,288).Levels(0,1.0,225,10,254).Sharpen(.8)
b=WavSource("d:\swep\test01.wav")
e=AudioDub(a,b)
c=AVISource("d:\swep\test02.avi").Crop(0,34,352,172).BilinearResize(576,288).Levels(0,1.0,225,10,254).Sharpen(.8)
d=WavSource("d:\swep\test02.wav")
f=AudioDub(c,d)
g=AVISource("d:\swep\test00.avi").Crop(0,34,352,172).BilinearResize(576,288).Levels(0,1.0,225,10,254).Sharpen(.8)
h=WavSource("d:\swep\test00.wav")
i=AudioDub(g,h)
return(i+e+f)
Since I audiodub each portion, I can set the delay (if needed) for audio playback by inserting .DelayAudio() after each wavsource line.
Also as you can see I do some cropping, resizing and cleaning up of the source (each to their own on this one).
Just though I'd share this with everyone. If anyone has a more efficient way of doing this I'll be more than happy to take any comments.
Cheers,
Ph2t.
Belgabor
26th May 2002, 16:00
Small (maybe dumb ;)) question:
Why dont you do the cropping/flitering after you stick them together? might be faster.
Regards
Belgabor
pandv
26th May 2002, 20:18
Maybe this response is not polite in this forum, but I don't use Avisynth for this task.
I merge the two mpg with TmpgEnc (if there are dat files I convert it with VCDGear).
Extract the audio with TmpgEnc (simple demux, delete video file).
Convert the audio with Lame (to mp3).
Open the mpg with VirtualDub and encode only the video to XVid (cropping and with TemporalSmoother 2, if there are noise). I don't change the resolution, nor the levels, if the source is correct.
Mux the audio with Nandub, and , voila!.
I never got sync problems.
Maybe the key is to join the two mpg's. I think is best also for encoding in two pass.
pandv
@Balgabor
It's not a dumb question :). I tried this with the return value set to the following:
return(i+e+f).Crop(0,34,352,172).BilinearResize(576,288).Levels(0,1.0,225,10,254).Sharpen(.8)
And is results in the same encoding rate. I believe the speed won't change since avisynth handles each stream sequentially (huge assumption!)
@pandv
Interesting suggestion, but I like to do my work in YUV space instead of converting to RBG (vdub filters do this) for speed reasons.
thanks,
Ph2t.
hakko504
27th May 2002, 08:55
Originally posted by ph2t
@Balgabor
It's not a dumb question :). I tried this with the return value set to the following:
return(i+e+f).Crop(0,34,352,172).BilinearResize(576,288).Levels(0,1.0,225,10,254).Sharpen(.8)
And is results in the same encoding rate. I believe the speed won't change since avisynth handles each stream sequentially (huge assumption!)
Actually AVIsynth produces each frame on request, therefor there is no speed difference. If you added a temporal filter however then you would not get the same result since it would in the later case get access to the whole film and not just each clip.
Beave
11th December 2002, 12:55
I also have sync problems sometime. My VCDs are usually 440 MB. I don't need to join them, since their only episodes. The problem is, that they are getting out of sync towards the end of the episode. It even happenes, when i simply demultiplex them in TMPEG and multiplex them again. Only the original MPG is in perfect sync.
Those faulty MPGs always result in playing the audio to early over time. So the audio is 1 to 2 seconds too short after demultiplexing.
Is there any Avisynth script to get the video and the audio from directshow directly? I'm asking, because WMP plays the original MPG fine.
How did you seperate the video to MJPEG and audio to PCM? Using VDub? Are you using directstream or full processing for audio?
Any suggestions?
Siku
11th December 2002, 18:57
What about conversion from DivX to SVCD? What kind of filters would you suggest to make hi-quality SVCDs? Maybe some Convolution3D and MSharpen? I've done about a dozen conversions and I'm just wondering what are the best filters for DivX to (S)VCD?
I've used this kind of script:
ConvertToYUY2()
Convolution3D(0,5,3,5,3,3,0)
LanczosResize(448,272)
AddBorders(16,104,16,104)
So, what do you think about that script? Do you have suggestions to add / remove / change some filters to improve the quality of SVCDs?
Regards,
Siku
InfoCynic
16th December 2002, 08:55
In my experience, there are a couple of common things that can help VCD to DivX conversions:
1. Most can be done as described with TMPG to get an mp2, then convert that to MP3 (I use BeSweet, take your pick here).
2. When doing your video, (and I just use Vdub, honestly, the color space conversion can't be worth much speed improvement, Vdub is already amazingly fast with MPEG-1 even with a resize filter), RESIZE IS ALMOST ALWAYS A MUST. Why? NTSC VCD is 352x240. The savvy user knows that's not 4:3. DirectShow fixes it at playback, but that doesn't help you when encoding. Calculate your target resolution based on a source of 320x240, and going above 512x384 from a standard VCD is likely to produce questionable results.
3. When muxing, if you get synch errors afterward, try using Nandub with a Frame Rate change to "Change so video and audio durations match." Amazingly, this fixes most common synch errors in VCD reencoding, but don't turn it on first -- sometimes, for whatever reason, I've seen differences up to .002 fps and it was still in synch. If this fails, try using graphedit to extract the audio to a WAV and encoding that to an MP3.
Never use "fix mpeg errors" if you use VCDGear at any step (e.g., extracting MPEG from BIN/CUE).
As for SVCD reencoding, just treat it like you're doing a DVD rip, it's all MPEG-2 after all. Set DVD2AVI to show all files and open the MPG. The only thing to really watch out for here is that SVCDs such as are released by "the scene," are frequently prone to bad mastering such that DVD2AVI information about NTSC/FILM and Progressive/Interlaced should ALWAYS BE MANUALLY VERIFIED. When in doubt, if it was a TV episode and the frame type wasn't FILM, try inverse telecine, but more information on DVD2AVI headers and deinterlacing can be found elsewhere on this site.
ppera2
16th December 2002, 21:33
I don't see any good reason to increase resolution. Playback filter should do it. So we spare storage place.
Also I agree that all video work can be done with Virtual Dub. I get extremly fast encoding with V Dub and VCD source and DivX 5.02 - over 100 fps on Athlon 1200.
Resize has only sense when converting from NTSC to PAL or vice versa, but this has no sense for DivX, except little to get correct A/R.
Beave
16th December 2002, 23:33
@InfoCynic
Thanks, for the Input. I will try the Nandub trick. I also do resizing to 352x256, but for what reason should somebody go higher than that?
How did you find out the difference of .002 fps?
My avs script usually only containes:
DirectShowSource
BicubicResize
@ppera2
I have an Athlon 1400 and I'm only getting around 60 f/s. I'm using GMC and BiFrames though. Are you sure about your speeds?
ppera2
17th December 2002, 00:16
Originally posted by Beave
@InfoCynic
@ppera2
I have an Athlon 1400 and I'm only getting around 60 f/s. I'm using GMC and BiFrames though. Are you sure about your speeds?
Speed is with DivX 5.02 without GMC and B frames. And I have DDR board, what is faster for some 15-20% than SDR board. In second pass I got even about 160 fps when use MV file. Of course must use fast recompress...
InfoCynic
17th December 2002, 06:51
Why resize higher... you can usually resize up a little bit without losing quality, depends on the source and the target filesize largely, but consider that you can spend the CPU cycles NOW to resize it or you can rely on your CPU at playback, and if you're making a divx for someone else, then you're relying on THEIR cpu at playback. CPU saved now can be applied to postprocessing later (which can really help compensate for the huge resize you're applying to a VCD when you watch it full screen). And a sharp bicubic resize now is probably better than what you're using at runtime.
Speed... 60 sounds reasonable if you have a sharp bicubic resize. I use XviD and I generally don't pay that much attention, but A) 60 fps is pretty good anyway, and B) to get much more than that I can't imagine you're able to run any filters...
Frame Rate Difference: Nandub can tell you if you have the video (with no audio) and the MP3 loaded, just go to the Video-> Frame Rate dialog.
ppera2
17th December 2002, 12:19
Originally posted by InfoCynic
Speed... 60 sounds reasonable if you have a sharp bicubic resize. I use XviD and I generally don't pay that much attention, but A) 60 fps is pretty good anyway, and B) to get much more than that I can't imagine you're able to run any filters...
Can we use filters in VDub with fast recompress ? :)
ph2t
17th December 2002, 23:48
I believe that the Filters option is greyed out when Fast Recompression mode is selected. Hence why I do all the "work" in the AVS script.
Ph2t.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.