View Full Version : Mix of progressive, telecine, and interlace
sonic41592
13th January 2020, 23:25
I have an NTSC DVD source which has a mix of 29.97fps telecine, 29.97fps interlace, and 23.976fps progressive. Each episode is mainly telecine, but has some scenes sprinkled through it that are fully interlace and some that are fully progressive. I've searched for months for a method to analyze the video to isolate the three different formats and perform the proper decombing. I've looked into AnimeIVTC, but it doesn't recognize the source since the overall frame rate is 28.5fps. I've tried using handbrake with both deinterlace an detelecine on at the same time with ok results, but still not that great. The only other way I've seen, you have to manually enter the frame numbers for each section, but there's no way I can do that for every episode. Any help would be greatly appreciated.
hello_hello
16th January 2020, 23:04
You shouldn't get anything but 29.97fps from an NTSC DVD, except if you force decoding as "film", in which case it'd be 23.976fps. Are you encoding a DVD after ripping it with MakeMKV by any chance?
I haven't used AnimeIVTC much but it has a hybrid mode capable of a variable frame rate output. It uses the TIVTC plugin for that. I don't know how much better than doing it with TIVTC on it's own it'd be.
For the TIVTC plugin you'd run two passes for a VFR output, The first pass to write the metrics files would look something like this:
TFM(Output="D:\TFM.txt").TDecimate(Mode=4, Output="D:\TDec.txt", Hybrid=2)
and the second pass is something like this:
TFM(Input="D:\TFM.txt").TDecimate(Mode=5, Input="D:\TDec.txt", tfmin="D:\TFM.txt", mkvout="D:\Times.txt", Hybrid=2)
As soon as you open the second pass script, the timecodes file is created, and you can add it to the command line for x264 VFR encoding like this:
--tcfile-in "D:\Times.txt"
If done correctly, the interlaced sections will be de-interlaced to 29.97fps and the progressive/telecined sections will be 23.976, but that's just the basic idea. The plugins have numerous options, and they probably won't work properly until you're decoding at the correct frame rate to begin with.
If you're decoding with LSmash, you need to tell it to obey repeat flags or it ignores them and outputs the average frame rate. This should give you 29.97fps:
LWLibavVideoSource("D:\Video.mkv", Repeat=true)
for FFMS2 it's this:
FFVideoSource("D:\Video.mkv", RFFMode=1)
DGIndex obeys repeat flags by default.
The above are just suggestions to get you started, mainly if you're okay with a VFR encode, but for anyone to give you decent advice you really need to upload a sample somewhere.
sonic41592
17th January 2020, 02:43
Thank you for the advice. What you're describing is exactly what I'm looking for. You're right that I have ripped the DVD with MakeMKV in order to separate out the episodes for easier file management. Would it be better to work with the VOB file? I'm also using FFVideoSource as the decoder, so I'll add that RFFMode=1. Would this work for a sample?
https://mega.nz/#!7jRVwADT!QTFPK5oLIYe50r-QVI3HQZzG2VAg4XkTciv9MeSoiA4
So if I understand correctly, I would make a firstpass.avs file that looks like
FFVideoSource("Sample.mkv", RFFMode=1)
TFM(Output="TFM.txt").TDecimate(Mode=4, Output="TDec.txt", Hybrid=2)
then encode it with FFMpeg, then create a secondpass.avs file which uses the encode of the first pass as a source:
FFVideoSource("Sampleencode.mkv", RFFMode=1)
TFM(Input="TFM.txt").TDecimate(Mode=5, Input="TDec.txt", tfmin="TFM.txt", mkvout="Times.txt", Hybrid=2)
and encode that with FFMpeg using the --tcfile-in Times.txt in the command line?
Sorry I don't fully understand the two pass encoding steps, but thanks again for your help! This is very informative
hello_hello
17th January 2020, 12:37
I've never used ffmpeg for encoding, only the command line version of x264, so I don't know if it has all the same options. You can always encode at a constant frame rate (don't use the timecodes file when encoding) and add it to the output MKV instead.
It's probably better to work with vob files if you can as you can index with DGIndex. I remuxed your sample as a TS file with TSMuxer to play with it.
For the first pass you don't need to encode. You run the script so TIVTC can create the metrics files. That is, you just run an analysis pass. Some GUI's have that feature. AvsPMod & VirtualDub2 probably do. I use MeGUI. Once it's run be very careful not to open the first pass script again otherwise it'll overwrite the metrics files and you'll have to run the analysis again.
Mind you I'm not convinced the sample isn't pure telecine, or mostly telecined. There seems to be baked in aliasing in the individual fields in places, and that probably confuses TIVTC. By lowering TFM's threshold though, it seems to find most of it so it can use QTGMC to clean it up (you'll need to use QTGMC as an external de-interlacer as I don't think TFM's de-interlacing will cut it).
I haven't had a chance to play around a great deal, but here's some sample encodes. Someone else may have a way to clean the occasional frame on a scene change that looks like bad editing. One sample is straight decimation to a constant 23.976 frame rate. I threw some filtering at them I copied from another script so I'm not claiming any cleverness there, but the scripts I used and the metrics files etc are included in the zip file. Animation really isn't my thing. It'd be more accurate to say I hate it. :)
Samples.zip (https://www.file-upload.net/en/download-13863253/Samples.zip.html)
PS. You should stick to a single thread, otherwise it gets confusing. ;)
manono
17th January 2020, 19:49
You're right that I have ripped the DVD with MakeMKV
Mistake number one. Decrypt using a real decrypter and use MPEG2Source on the D2V file that results from indexing the VOBs in DGIndex.
DVDDecrypter (if this thing doesn't have modern encryption in it) can separate the episodes while decrypting. PGCDemux can separate the episodes once you have the DVD files decrypted to the computer.
Since you don't seem to be making another DVD, then just bob the whole thing to 59.94fps and save yourself all the headaches.
Balling
31st August 2021, 17:03
Ffmpeg can do it... https://trac.ffmpeg.org/ticket/3968
Katie Boundary
1st September 2021, 05:24
Mistake number one. Decrypt using a real decrypter and use MPEG2Source on the D2V file that results from indexing the VOBs in DGIndex.
Translation:
1) Use Smartripper to copy .VOB files from the disc to your hard drive
2) Index the .VOB files using GDindex. This will produce a .d2v file.
3) Load the .d2v file into AVIsynth using mpeg2source().
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.