Guide to dealing with interlaced sources
Added August 2nd, 2007: See this post for a more up-to-date sample script: http://www.kvcd.net/forum/viewtopic.php?p=127192#127192
OK, since I've been writing the same things a lot recently, I decided to write a small guide regarding interlaced sources. It's also easy to keep the information up-to-date as recommended scripts and plugins tend to change over time. If anyone has any suggestions, corrections or questions, please post them in this thread so it will be easier for me to notice them. Note that I assume you know how to use Avisynth, load plugins etc. so I'm not answering questions related to those areas in here. Read http://www.avisynth.org/YourFirstScript if you don't know that stuff. This guide applies to both PAL and NTSC. It's meant for keeping the material interlaced, so it's mostly for DVD encodes. The only additional plugin you need is KernelDeint. You should have version 1.5 or above since those versions include the function KernelBob which is used in the script. The plugin can be downloaded at http://www.avisynth.org/warpenterprises or at http://forum.doom9.org/showthread.php?s=&threadid=81322 . Download it and extract to your Avisynth 2.5 plugins folder. The default it is C:\Program Files\Avisynth 2.5\plugins. The rest of the plugins depend on what filters you use. Step one. Determining the field order Create a script with the following lines in it: Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") Step two. The script I'll only give a very basic script here. You can add all the filters you normally use and they can be used just as with any progressive source. The only thing is that they need to be placed between the KernelBob and SeparateFields lines. Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") That's it! Now you just have to encode the material correctly, i.e. encode as interlaced and with a correct field order set. -------------------------------------- And upon request, two ways to convert pure interlaced 29.97fps (NTSC) stream to a 25fps (PAL) one. If your source material isn't pure interlaced video, you should either enable Force FILM in DVD2AVI or do an inverse telecine by using Telecide and Decimate, both in the Decomb package. Don't forget to do the framerate conversion for the audio as well! First method This method will result in a 25fps progressive video, so you can encode as progressive and save some bits. The smoothness will take a slight hit, but there is no way for a perfect conversion without expensive professional programs and dedicated hardware. Download MVTools here : http://jourdan.madism.org/~manao/MVTools-v0.9.3.zip First, determine the field order as explained earlier in this post. Then use this script to encode: Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") Second method See Scharfis_brain's method as well, it's later in this thread. This method will result in a 25fps interlaced video. There may be artifacts and blended fields, but motion should be smooth. Once again, determine the field order. Then use this script, encode as interlaced with the correct field order set: Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") |
Hi Boulder, I like your guide.
Can you post something about NTSC interlaced to PAL? |
You probably don't want to go that way :lol:
There are two ways to convert a pure interlaced 29.97fps stream into a 25fps one. One will result in a progressive video and the other in an interlaced one. I'll post them both to the first thread. You'll have to remember that I've not tried either one of them myself so they may or may not work. Your Mileage May Vary, as they say :wink: |
The two methods for 29.97fps to 25fps conversion are now added to the first post. They can be extremely slow, especially the one including the function MVConvert60ito24p(). If it's too slow, it might be a good idea to put ConverttoYUY2() at the end of the script and save in HuffYUV in VirtualDubMod (using fast recompress) if you have the required huge amount of diskspace and then process the saved AVI file directly in TMPGEnc/CCE/FreeEnc.
|
Great guide Boulder! :D
I never tried "KernelBob" before. I'll make some tests with it. |
The good thing about KernelBob compared to a simple Bob() is that being a smart bob it keeps a lot more details and gives a slightly sharper image too :D
|
Nice guide ...
Also do have a look at TMCbob() as it gots some more nice advantages. I dunno remeber now if in case of scaling or fitering. But you should have a look at it. |
How about JDL functions?
|
The functions are faster and nice *but* they produce a blurrier image. It's also not a "real" way to process interlaced material as they simply put top field on the top of the frame and bottom field to the lower part of the frame.
There is always unwanted interference in the part where the top field area ends and bottom field area begins, even with the flip=true parameter. Thus this approach cannot be recommended if you want good quality. The latest way is by using TDeint() as the smart bobber, but it's way too slow to be useful. |
I have The Matrix in PAL format and DVD2AVI info shows me that it is interlaced. But I can't see any combing effect. Also previewing with VirtualDubMode the diagnosis scripts with assumeTFF and assumeBFF, it plays smooth both scripts.
How must I understand that. Is there a general rule for PAL material? |
The material is progressive. You must trust your eyes, DVD2AVI will only tell you how the stream is flagged and must not be trusted.
|
How about Bitrate Viewer? Can I trust the specs the program gives about a movie?
|
Nope, it will probably report the same as DVD2AVI. The only thing you can trust is checking for the combing by your own eyes.
99% of all "Hollywood" movies are progressive. The 1% comes from incorrect transfer from NTSC to PAL. If you know that the original material is in fact progressive (FILM) and the PAL version has combing, you should go for the Restore24 method to restore the original progressive frames at 23.976fps and then speedup the video and audio to 25fps. |
If PAL Material is combed and its shure that the original source WAS shot on Film, then the following steps should be used in the following order of try outs:
1. mpeg2source("CombedPALmovie.d2v") doubleweave().selectodd() A simple inverse of a "static" field shift will be performed, and if that not works... 2. mpeg2source("CombedPALmovie.d2v") Telecide(order=1,guide=2,post=0) An inverse "dynamical" field shift will be performed, and if that not works... 3. mpeg2source("CombedPALmovie.d2v") Restore24(AA,BB) Restore24: http://forum.gleitz.info/attachment....chmentid=68866 Trys to inverse a fieldblended decimation/conversion from 29.976 to direct 25fps 4. And finnaly if you deal with StarTrek TNG Sources you can try Scharfis_Brain's "repairPAL_TNG_DVD()" Function. It can be found at doom9.org but as it has become that damn slow to search (that forum) you should search by yourself |
Ah, I forgot field/phase shifting..thanks for clearing that up!
|
Better do the NTSC <-> PAL conversions this way:
Code:
function tmcbob(clip i) - much more motionblur - requires footage shot with 1/60 (NTSC) 1/50 (PAL) second shutter, shorter shutter will result in ghosting. advandages: heavily reduced annoying border scrolling! (also, I tend to use mvconvertfps for that task, but it currently has some weird behaviours making it not really useful for genral purposes :( ) |
Hi:
1 - Where to put Kwag's MA script or Dialhot's V series scripts in following one. (Post complete sample script please). Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") 2 - I read in avisynth.org web site that not all interlaced video is fieldbased. Is it true? What percentage of interlaced video is not fieldbased (or is framebased)? |
All interlaced video has two fields per frame. If the two fields are captured at different times, consecutively, then the video is standard interlaced. If both fields are captured at same time, then the video can be called progressive since it is possible to re-generate a progressive frame from the two fields. A DVD usually is progressive since both fields are captured from one film frame.
|
You'll simply place all the processing in the portion between the conversion from 60i to 24p and AssumeFPS(25). After the MVConvert60ito24p() line the video is progressive and at 23.976fps.
Using MVConvert60ito24p() is dead slow so you might want to save an intermediate HuffYUV compressed file (remember to convert to YUY2 in the script if you do that) and then process this file as you normally would process any DVD. Another option is to use the version Kwag posted, it will produce a slightly softer video but looks good too. Code:
MPEG2Source("path\clip.d2v") or AVISource("path\clip.avi") |
@Boulder
Please, an answer to my second previous question? |
I think Peter explained it well. See also here : http://www.kvcd.net/forum/viewtopic....14621&start=16 , especially Scharfi's post about the patterns observed when the unknown clip has been bob-deinterlaced.
|
Edited the first script a little : AssumeBFF() added to ensure a certain field order in the final video.
|
@ Boulder
thank you my friend.... i remeber when you was helping me in lots of pms to understand how it works round 1 or 2 years ago . thanks again(past,present and future) ! :D |
@Boulder: Could you explain me how frames are managed in ntsc -> pal both methods.
I mean, you have 29.97 interlaced, in one of the scripts you use assumefps(25), it is no drop frames, but movie time changed, isn't it? The other one uses convertfps(50). What does it mean? 29.97 to 50 fps. If convertfps works without inserting frames, I don't understand how do its work. How we must to manage audio in both scripts? It would be possible convert from 29.97 interlaced to 25 fps droping frames (less frames, same movie time) with a good result? |
Assume FPS() is used IF you just pitch up from 23.976 to 25.000 (as that MVconvert60ito24p() does pre-convert to 23.976 out of 29.97 real interlaced )
Convertfps() is used IF you perform a fieldblended conversion out of real NTSC 29.97 interlaced video to 25.000. The 29.97 will be bobbed to the fieldrate (=twice the framerate) and a convertFPS(50) will fieldblend convert to full PAL fieldrate, finally that resulted 50fps PAL stream will be reinterlaced to its PAL framerate 25.000 |
How about this 2 questions?
Quote:
|
1. The audio sync is kept as assumefps(25,true) (I see that should be added!!) in both scripts do force the 23.976 resulted stream to finally end up in PAL 25.000.
2. In a direct way: NO. As it would bekome noticable jerky. But if you do a fieldblended conversion from 29.97 to 25 in the known bobbed way then it works but the result is still interlaced. http://home.arcor.de/scharfis_brain/...esInterlacing/ Its in german but THE best bible related to interlaced sources/scripting! An online translator could make it understandable for you. |
Hi everyone and thanks to Boulder for starting this post.
I just started to work on my own personal videos (captured with a PAL DV camcorder) hence I'm new to the subject of interlaced video. After hours of reading (through this forum notably), I discovered that this is tricky and most confusing for dumb newbies as myself (I'm trying hard to learn though). I therefore still have questions for the experts here. OK, after editing my video, I end-up with an avi file in PAL format, interlaced BFF, which I want to turn into KVCD to be viewed on PAL TV Here are my questions: 1) Is it right to assume that I do not need to deinterlace the video, since I will not watch it on a computer, but on TV only? 2) Or is there any reasons why I should still deinterlace it? 3) I'm not sure to understand the purpose of Boulder's sript: Quote:
Are there cases where you don't need to go through all this deinterlace-interlace process while encoding to KVCD (if you do not apply any filtering for instance)? 4) Can Kwag optimal MA script be used with Boulder's above script? 5) Sometime ago, in another post Boulder was suggesting the following script for interlaced videos Quote:
a) Bob-deinterlace - apply usual Script - Interlace or b) SeparteFields - apply usual Script separately to even and odd - Interleave(even,odd) - Weave Which is the best of the 2 methods for Kwag's MA script? 6) Lastly a small technical issue. In its initial post, Boulder says Quote:
Sorry :oops: for asking so many (stupid) questions and thanks for your help Surfinette A suggestion if I may, it would be worht having a Sticky post on Interlaced video script with the final (?!) conclusions of the experts |
Ill try to answer you as far as I can: :wink:
1.Yes,its no need to deinterlace for Tv viewing,the encoded video looks better when its interlaced(my opinion!) 4.Im not sure I never use it,I use Boulders. 5.someone else must answer to this 6.Goto "MPEG Setting"-"Advanced"-"Video Source Setting"-"Field Order" and yes it has to be set as it was in the original video,if not you get a shaky picture on your tv. ---------------------- viking EDIT:Read this about interlace/progressive stuff http://www.kvcd.net/forum/viewtopic.php?t=9808 it explains a lot |
Quote:
Quote:
Quote:
Quote:
Quote:
Code:
Mpeg2Source("Your_D2V_Source_Here") Quote:
|
Boulder wrote:
Quote:
KernelBob(order=0,sharp=true,threshold=7) AssumeFrameBased() # # AssumeBFF() SeparateFields() SelectEvery(4,0,3) Weave() :?: :?: The bob documentation on AviSynth page told me this: Bob takes a clip and bob-deinterlaces it. This means that it enlarges each field into its own frame by interpolating between the lines. The top fields are nudged up a little bit compared with the bottom fields, so the picture will not actually appear to bob up and down. However, it will appear to "shimmer" in stationary scenes because the interpolation doesn't really reconstruct the other field very accurately. Or does bob(),kernelbob() and others the deinterlacing job another way than fielddeinterlace() and smoothdeinterlace() :?: And yes I know that in interlace video the topfield-lines and bottomfield-lines are "brodcasted" at different times,and thats the reason why its hard to get the same quality when we deinterlace? Deinterlaceing is a "compromise" between lines as the lines where broadcasted at different times :?: In other words,its not possible to deinterlace and get the same quality as a film thats progressive originally?? Or am I totally lost(again) :?: :lol: ----------------------- viking |
Quote:
Bobbing only affects one field at a time, which means that it separates the fields and enlarges them to full height, that's why you get a doublerate output when using a bob filter. "Regular" deinterlacing either interpolates or blends information from the two different fields, "combining" them and that's why the field information is lost and cannot be restored. Quote:
Quote:
|
Quote:
So after processing the filters the reinterlacer brings the fields back to their orig height and they will be weaved again. If you just do denoising and/or a simple cropping like 720 to 704, I would just use a simple Bob(0,x) instead of an adaptive working Kerneldeint. If kerneldeint is used, then set it to th=0 and sharp=false. This keeps the fields in a best condition for denoising. But if resizing is used, then kernelbob incl. ath and sharp is the choice. |
Thanks, that were fast answers !
Boulder wrote Quote:
I guess I was not too clear with my 3rd question: Quote:
ie, just this very simple script: LoadPlugin("D:\Video\AVISYN~1.5PL\Mpeg2dec\MPEG2D~ 1.DLL") AVISource("E:\Video\MAGIX\MYAUDI~1\titi.avi",False ) BicubicResize(480,576,0.0,0.6) Because as I move on on how to deal with my video to make a nice KVCD, I’m wondering whether I need any filtering at all since the source is very high quality (DV-AVI) and I don't necessarily need to fit a long video on 1 CD. Probably again a stupid thought, which doesn’t fit in this thread anyway! Surfinette |
I'd do interlaced encodings with DVD target only so SKVCD would also be out of the question. Unless the average bitrate would be around 2000kbps or so. Note that only MPEG-2 supports interlaced encoding.
Processing an interlaced video as it is, is a big no-no. You can crop it but you'll have to be extra careful. You can probably even get away with resizing horizontally, but if you use any overscan (as you should), you must resize vertically as well. That's where you need the bobbing. You should also convert the colorspace in your script instead of blindly trusting any external codec, and the conversion is best done when the material is in progressive state, that is, bobbed and not yet re-interlaced. |
Boulder wrote:
Quote:
Quote:
AviSource() Bob() Info() and got this result: Frames per second: 50 then I added this to the script: AssumeBFF() SeparateFields() SelectEvery(4,1,2) Weave() and got this result: Frames per second:25 I did the same test with kernelbob() and the results were the same. then I did test with Fielddeinterlace(),Smoothdeinterlace() and TomsMoComp(),and get this result: Frames per second:25 So I think I (finally :wink: ) get the point. :!: But a question,when I load the first script in TMPGEnc,it switches(of course) to 50 fps,should I change it to 25 or just encode as it is? (im talking of bob-deinterlacing here) if I encode with 50fps will that do anything "wrong" when playing the clip on DVD-player? And whats the best deinterlacing method,bob/kernelbob or field/smoothdeinterlace? (When we want to keep the video deinterlaced) And finally when I want to encode interlaced(keep the video interlaced) the bobs() is the only useful option as they dont destroy the fields?right? Thanks ------------- viking |
Quote:
Quote:
Quote:
|
Boulder wrote:
Quote:
1) SKVCD is MPEG-2, isn't it? SKVCD should therefore support intelaced encoding, assuming sufficiently high bitrates? 2) I intend to make short videos (I don't want to bore family and friends :wink: ): 30-40 min on one CD (maybe 50 min max). I assume therefore that I could reach close to 2000kbps bitrate. I guess it is still worthwile to use SKVCD at such bitrates... or should I do plain standard SVCD? |
1) yes and yes
2) the only difference between SVCD and SKVCD is the notch matrix and the GOP length - so you should go for SKVCD anyway since it offers better compression and better quality. Just make sure you use the CQ mode in TMPGEnc, and you should try whether the encode turns out to be good or bad when encoded as interlaced. It depends big time on the source material, if there's lots of motion, it demands a lot more bits too. |
@Surfinette,
if your source is DV,and you don't want any filters, try this script:(its for KSVCD). Quote:
the result in high "action" scenes. --------------------- viking |
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.