View Full Version : CVD Script advice
calvore
18th December 2002, 16:03
Wow, there is so much to learn with video. I wondered if I could get a little advice. I am going to spend a good amount of Christmas break capturing past home videos from CompactVHS tapes using a rented JVC VCR with a built in time base correcter to hopefully get the best capture possible. The final output media will be CVDs encoded with TMPGEnc at CQ=70 (or maybe more) with a max bitrate of 4000 (the DVD player doesn't seem to object). Ultimately, I would like to move these to DVD in the future, so audio will also be captured at 48KHz.
I am capturing with a DC10+ capture card in Windows XP at the highest setting possible using thier MJPEG codec. Since it only has Directshow drivers, I can't use VirtualDub (VFW only) or anything else that I am aware of to capture to a different codec.
It will be a 640x480, interlaced NTSC video. I also have installed and registered the PicVideo MJPEG codec for decompression.
I would like to do some filtering in AviSynth before sending it to TMPGEnc. I have read tons on these forums in the past, but wanted to get a little advice on the script I have come up with before I start this. I only have the VCR for a couple days, and I don't have enough room on the hard drive to capture everything before I give the VCR back so I need to encode some of the videos, and I am only going to have the one shot to get it right before I'll have to delete the source.
Here is the script I have so far:
LoadPlugin("C:\video\avsfilters\Fluxsmooth.dll")
LoadPlugin("C:\video\avsfilters\conv3d.dll")
AVISource("myvideo.avi")
Fluxsmooth(5,5) // Start with low settings for minimal filtering
Convolution3d (preset="movieHQ") // Low settings for minimal filtering
Bilinearresize(352,480)
AddBorders(8,8,8,8) // Or something more if this doesn't show up outside the overscan area and onto the screen
So my questions: I assume the MJPEG codec is in RGB colorspace??? Do I need to do any colorspace conversions? Since I am dealing with an interlaced source, do I need to use these filters differently, or do they account for an interlaced source? I read somewhere about separating the fields to above and below each other in the same frame, applying the filters, then mixing them back together, but I can't find exact info on how to do it. Is it necassary?
Anything wrong with the filters above? Ordering?
Any other advice appreciated.
SansGrip
18th December 2002, 17:47
Originally posted by calvore
I read somewhere about separating the fields to above and below each other in the same frame, applying the filters, then mixing them back together, but I can't find exact info on how to do it. Is it necassary? Bear in mind that your destination format must support interlaced material for this to work. I've never used CVD so I'm not sure on the specs, but you'll want to double-check that first.
calvore
18th December 2002, 18:09
CVD is a extension (sort of) of SVCD, I guess their question on which is a subset of which.
Anyway, it is MPEG2 352x480 interlaced NTSC video, other than that the limits and specs are the same as SVCD.
SansGrip
18th December 2002, 19:11
Originally posted by calvore
CVD is a extension (sort of) of SVCD, I guess their question on which is a subset of which. Well then if it's MPEG-2 and you're gonna watch these discs on an analog TV then you're right to say you want to leave it interlaced. In that case, you should investigate SeparateFields and Weave. I've never done it, but I guess it would be something like:
AviSource("socks.avi")
SeparateFields()
# Run nifty filters
Weave()
Also, since MJPEG should already be in YUY2 format and you're going into TMPGEnc, the only colourspace conversion you might need to do (depending on your codec and VFAPI setup) is a ConvertToRGB right at the end.
calvore
18th December 2002, 19:58
Hmm, MJPEG is already in YUV2? Is there a way to tell what colorspace a codec is using? Apparently avisynth is aware of the colorspace, so couldn't a Version() type filter print out the colorspace being used when the video is opened?
What could be the effects of letting TMPGEnc doing the conversion? When I was learning the settings for TMPGEnc I was opening my MJPEG .avi files directly into TMPGEnc and encoding from there. I noticed that my encoded files looked a little washed out with color though the limanance looked very similar. I checked the 'output as YCbCr . . .' and re-encoded and things look much better now. It isn't a DV source (meaning a DV camcorder) but it is a TV converted source from an analogue camcorder.
Could this have been an artifact of not converting to RGB before hand?
SansGrip
18th December 2002, 21:13
This is straying somewhat off-topic, so you might want to move follow-ups to the TMPGEnc forum...
Originally posted by calvore
Hmm, MJPEG is already in YUV2? Is there a way to tell what colorspace a codec is using? Open it in VDub and look at the File Information.
What could be the effects of letting TMPGEnc doing the conversion? If you use the ReadAVS VFAPI plugin and have a non-MS YUY2 decompressor installed, TMPGEnc will convert just fine. If you don't, use the VFW-compatible plugin and do a ConvertToRGB at the end of the script.
I checked the 'output as YCbCr . . .' and re-encoded and things look much better now. Don't check that, it'll mess up your ranges, at least with ReadAVS. See this thread (http://forum.doom9.org/showthread.php?s=&threadid=37082&highlight=output+basic+ycbcr).
seewen
18th December 2002, 23:01
I'm doing CVD too.
CVD is not "an extension" of SVCD. It's a real DVD resoltution (1/2 DVD ).
But my 2 cents advices are :
-Use CCE SP to encode. Better for MPEG-2 than TMPGEnc.
-4000 for bitrate is too much. You should use Variable Bitrate (Multi-pass Encoding. 3-4 pass with CCE). With Min=1200, Max=2530, Avg=1900-2400.
At least you should compare this with 4000-CBR. I'm sure you wouldn't see any difference. Just that with a bitrate @4000 you could only have 25 minutes per CD-R.. And with The method I gave you, I easily reach 60-80 minutes per CD-R, with great quality (depend of the movie, the ratio, etc..)
-If you really don't want to use CCE, you should use "2-pass(VBR)" Mode of TMPGEnc. The result will look better than CQ-Mode for same bitrate. (but you should at least try CCE SP ;-) )
-And finally you really should use a "sharp" filter. Specially if you have (like me) a 16/9 TV. Beccause on such TV (less on standard 4/3), CVD lookes more "blur" than SVCD.. Due to the difference of resolution.
I find that "Unsharp Mask" (WarpSharp.dll) gives very good result. And it correct the "blur" aspect. (Unfilter.dll, Focus2.dll/sharpen2 and MSHarpen.dll are really good too. You should try them too, and maybe try 2-3 at the same time.)
I know you didn't asked for this.. ;-) But you should really have a look at those propositons ;-)
Greets
Faceman101
18th December 2002, 23:35
CVD is the Chinese version of SVCD and also valid 1/2 DVD specs.
If I have a VHS cap or make a Divx movie into something I can watch on TV, I use CVD with a CBR of 3000kb. Going over that really isn't needed.
What the original poster is asking I do not know or have any experience on. I never capped using MJPEG.
calvore
19th December 2002, 03:38
Thanks for all the great advice. I haven't had a chance to check out any of the sharpen filters, but I will look. Do you have a suggestion of one to start with that works well with real video source, and not animation? I started reading a few threads on them, and a lot of comments about how great they are for animation but I didn't see much about non-animation.
I am using a max bitrate of 4000, not a constant bitrate of 4000. I am not worried about only fitting 25-35 minutes on the disc because they are short clips of family videos, usually less than 5 minutes long each. I am more interested in them being of excellent quality, and I believe CVD is the best for me. KVCD are excellent for lowest bitrate, but since I am willing to give it more bit rate, I don't think they are the way for me.
Here is the script I ended up creating:
LoadPlugin("D:\avsfilters\Fluxsmooth.dll")
LoadPlugin("D:\avsfilters\convolution3d.dll")
AVISource("D:\capture\test.avi")
a = SeparateFields()
b =
a.SelectEven().Fluxsmooth(15,8).Convolution3d(preset="movieHQ")
c = a.SelectOdd().Fluxsmooth(15,8).Convolution3d(preset="movieHQ")
Interleave(b,c).Weave()
Bilinearresize(352,480)
Crop(0,8,352,464)
AddBorders(0,8,0,8)
ConvertToRGB()
I am very happy with the results so far.
A few questions: There seem to be quite a few tools out there, is there one where I can display the before and after results of my filters quickly, such as in VirtualDub with left and right?
Also, I opened up the video in VirtualDub to check colorspace and it simply says: PicVideo MJPEG Codec
I noticed if I open the AVS file (without the ConverttoRGB) it says YUV2 :-)
Thanks for the help all.
Asmodian
19th December 2002, 05:10
I am just curious but why do you do the SelectOdd and SelectEven when doing the same thing to both of them.
Shouldn't this script give the same result with (albeit slightly) less cpu usage?
LoadPlugin("D:\avsfilters\Fluxsmooth.dll")
LoadPlugin("D:\avsfilters\convolution3d.dll")
AVISource("D:\capture\test.avi")
SeparateFields()
Fluxsmooth(15,8)
Convolution3d(preset="movieHQ")
Weave()
Bilinearresize(352,480)
Crop(0,8,352,464)
AddBorders(0,8,0,8)
ConvertToRGB()
SansGrip
19th December 2002, 05:53
Originally posted by calvore
I am more interested in them being of excellent quality, and I believe CVD is the best for me. This may sound like a lot of work, but since you mentioned that you only have the VCR for a couple of days and not enough HD space to keep those AVI files around, why not buy a shiny new 50-pack of CD-Rs and use a file splitter to archive the AVIs straight to CD?
It can take a lot of time to play with settings in order to achieve the best possible encoding of any given source material, and generally the more you do to improve the signal/noise ratio the longer it takes to encode. If you have the original AVIs archived on CD-R you then have all the time in the world to do the actual encoding.
The other advantage to this approach is that while you can't watch those discs in your standalone, you do have the original unaltered source material available should some fancy new encoding method emerge. What's more you can encode it more than once, perhaps doing one high-quality but non-standard version for yourself, and regular VCDs for relatives with less flexible players.
Not only that, but once DVD writers become more affordable you can then re-encode at very high bitrates and make your own DVDs of the same material.
Just a thought :).
calvore
19th December 2002, 06:06
I could be wrong, but this is how I understand it. I hope I can explain it clearly.
SeparateFields() will break each field out into its own frame. One field is half a pixel off from the other field, which means going from field one to field two if treated as frames will cause the image to bounce up and down even if something is stationary. A median filter such as FluxSmooth will see a pixel in frame 1 at some level, see that it moves up (or down) in intensity in frame 2 since it is half a pixel in space difference, and in frame 3 it is back to the same value. The filter will interpret this as noise, even though it isn't, and remove it.
So you want to process each field independently of the other field to avoid interpreting the 1/2 pixel shift of the field as noise. This is done with the select odd and select even. Note, this is only necassary with a temporal smoother. With a spacial smoother, you can just separate the fields and process each one because the relation from one field to the next won't matter.
A way around this is to use some sort of bob filter to shift the pixels of one field by half a pixel. Well, this requires interpreting data through some sort of interpolation of the pixel above and the pixel below the half way point you are interested in. That way the stationary pixels will mostly line up from one field to the next. The problem is, this creates an average of two pixels since there is no way to tell what the actual pixel is half way betwean these two, meaning one field will be blurred, albeit very minimally. If you did this then you could process the motion that does indeed exist betwean the two fields with the script you posted.
So for me, I decided that temporal filters do quite well on film sources at 24 fps even though more motion could potentially exist between frames (thus less temporal smoothing) when compared to a 60 field/sec source. If the filters do well at motion in 24fps, they should do fine with every other field at 30 fps and I don't have to do any bobs or averaging of one field in order to shift it up.
Now, the big question is, can the eye detect the difference when you are talking about 1/2 pixel shifts? How much "noise" is introduced from doing a bob? How much static "motion" would be detected as noise if you didn't do a bob but still processed every field (not selectodd)? I have no idea :-) However, I am quite please with the result of processing every other field which should be in line spacially with eachother.
Wilbert
19th December 2002, 11:08
Not only that, but once DVD writers become more affordable you can then re-encode at very high bitrates and make your own DVDs of the same material.
Like someone said in this thread CVD's are DVD compliant (expect for the audio). The audio of CVD must be 44.1 kHz and for DVD 48 kHz. So what you could do is making CVD's with (MP2) audio with a samplerate of 48 kHz (your dvd player can play that anyway), of course you can also upsample them at a later stage.
I am using a max bitrate of 4000, not a constant bitrate of 4000. (...)
Of course this is no problem if your dvd player can play those files, but keep in mind (as someone said in this thread), according to the specs the max. bitrate must be 2520.
Asmodian
20th December 2002, 05:23
@calvore
Ah, of course - I just totally forgot about that pixel shift between fields :)
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.