Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th January 2020, 22:12   #1  |  Link
sonic41592
Registered User
 
Join Date: Jun 2019
Posts: 36
Help Deinterlacing Troublesome DVD

I have an old DVD collection of cartoons that I'd like to work on deinterlacing. The problem is that each episode is a variable frame rate, and switches scene to scene between 30 fps interlace, 24 fps progressive, and 30 fps hard telecine. I've checked around for a long time for a way to properly deinterlace/IVTC the episodes, but nothing seems to work correctly. If anyone knows of an Avisynth script that can fix this, I'd really appreciate it.

I was coming here to look for advice on creating an Avisynth function that could break apart the video into sections by frame number, determine if each section were progressive, interlaced, or telecined, reconstruct the progressive frame at 24 fps (for progressive and telecine sections) and deinterlace the 30 fps (for the interlaced sections), and stitch all of them back in order. I know mkvextract can create a timestamp for each of the frames, and that can be used to find the fps for each individual frame. The 24 fps frames actually alternate between ~30 and ~20 fps, so the average across them is 24 fps. The frame numbers that are listed as 24 fps can be trimmed and left untouched. The 30 fps sections can then be analyzed over all of the frames to check for combing, like in this section of Avisynth interlace detection

http://avisynth.nl/index.php/Interla...Synth_analysis

This would tell which groups of frames were telecine (two or less combed frames per five frames) or interlace (more than three combed frames per five frames). It could use the frame numbers of each section to trim each group, then perform TIVTC and QTGMC respectively, and concatenate all of the sections. It would need to create a new timestamp text file so each frame can be labelled with a new timestamp so that mkvmerge could create a variable frame rate mkv.

I have some (limited) coding knowledge, but have no idea where to get started to put this together. I'd really appreciate any help or focused tutorials on what this project entails. Thanks!
sonic41592 is offline   Reply With Quote
Old 16th January 2020, 01:50   #2  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Samples would be welcome.
An easy way: Since with most cartoons you will have to reconstruct orphaned fields anyway,
so I can globally suggest (Q)TGMC to bob up to double framerate (50p or 59,94p, whatever the source DVD was,
and I am not covering blended fields here). All timing is kept, no need to go VFR.
Only if you indeed need to have individual frames, then: VFR.
(BTW if the VFR objective was bit saving by any means:
You won't save that many bits by doing VFR,
encoders like x264, x265 analyse the almost similar content and won't spend so much more bits on the repeated frame.)
Next it depends what the playback device shall be.
If Blu-ray compatible: resize to 1280x720
(SAR 1:1 provided, so if narrower than 16:9 black pillarboxed / wider than 16:9 black letterboxed),
encode using x264, author to .m2ts as Blu-ray.
If .mkv or .mp4: resize to what your playback devices likes most, SAR 1:1 provided, encode using x264 or x265.
BTW, Staxrip does this all in one step, maybe you need tsMuxeR for Blu-ray in the end.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 16th January 2020 at 01:54.
Emulgator is offline   Reply With Quote
Old 16th January 2020, 05:51   #3  |  Link
sonic41592
Registered User
 
Join Date: Jun 2019
Posts: 36
I tried using QTGMC for the video, but the 24 fps progressive sections are ran at 59.94 fps, which makes them play sped up compared to the telecine and interlaced sections. It also has cause some frames to backtrack and flicker what should be smooth motion, as well as makes the picture wavy looking if that makes any sense.

https://imgur.com/a/rPupTFW

I was trying to keep the number of duplicate frames at a minimum with the VFR because I'm planning on upscaling the series with waifu2x, so the fewer images to run through the program the better. The end player will be my computer/plex, and I typically use handbrake to encode in x265, so I can adjust the aspect ratios there.
sonic41592 is offline   Reply With Quote
Old 16th January 2020, 16:39   #4  |  Link
SaurusX
Registered User
 
Join Date: Feb 2017
Posts: 135
It looks like a couple of problems may be happening here. Specified field order and/or the indexing process you're using to frame serve could be causing the back and forth motion. If you're indexing the VOBs with DGIndex make sure you have the "Honor pulldown flags" turned on.

But at the minimum, the initial part of your script would be helpful to see.

And really, even if you're looking to minimize conversion time with Waifu2x it's not to your advantage to feed it a variable rate video file. What process are you expecting to use to recompile the upscaled frames in order to keep the correct frame rates? You're going to have a hell of a time.
SaurusX is offline   Reply With Quote
Old 16th January 2020, 20:37   #5  |  Link
Motenai Yoda
Registered User
 
Motenai Yoda's Avatar
 
Join Date: Jan 2010
Posts: 709
You should try

1pass vfr
Code:
tfm(pp=0)
tdecimate(mode=3,hybrid=2, mkvOut="timecodecsMkv.txt")
2pass vfr
Code:
tfm(pp=0,output="tfmout.txt")
#first pass
tdecimate(mode=4,output="timecodecs.txt")
#2nd pass
tdecimate(mode=5, hybrid=2, cycleR=1, input="timecodecs.txt", mkvOut="timecodecsMkv.txt", tfmInput="tfmout.txt")
qtgmc doesn't go well as the mcm is 119.880fps not 59.940fps
__________________
powered by Google Translator
Motenai Yoda is offline   Reply With Quote
Old 17th January 2020, 03:39   #6  |  Link
sonic41592
Registered User
 
Join Date: Jun 2019
Posts: 36
Sorry I didn't post a sample earlier, hopefully this can be of use:
https://mega.nz/#!7jRVwADT!QTFPK5oLI...XkTciv9MeSoiA4
I should have mentioned that I used MakeMKV to separate the DVD into each episode for easier file management. So the code for the gif was just:
FFVideoSource("Sample.mkv", RFFMode=1)
QTGMC()

As far as maintaining the correct framerate after upscaling, I was just going to use an MKVExtract command to pull out the timestamp for each frame, use FFMpeg to save each frame as a .png, upscale each frame, use FFMpeg to put the upscaled .png into video, and MKVMerge the extracted timestamps back on each frame.

I tried using the 2pass method Motenai Yoda provided, but it showed a screen saying TFM doesn't have a named argument tfmInput. Was that supposed to read tfmin instead?
sonic41592 is offline   Reply With Quote
Old 17th January 2020, 04:41   #7  |  Link
Motenai Yoda
Registered User
 
Motenai Yoda's Avatar
 
Join Date: Jan 2010
Posts: 709
yepe, mistype (I was going by ancient memories)

also more examples
Code:
https://github.com/pinterf/TIVTC/blob/master/examples/TIVTC%20-%20Common%20Usage%20Examples.txt


                                     TIVTC Common Usage Examples

                                  (Last Updated:  27 November 2004)


      This file lists some example scripts for dealing with common cases for which you would use
   TIVTC.  It assumes, however, that you have at least skimmed over the README's and know the
   different parameters.  It also assumes you know what "hybrid" and "vfr" mean, what an mkv
   timecodes file is and how to use it if you are looking into hybrid processing.  All examples
   assume we are using an mpeg2source()... and use TFM's d2v parameter to obtain the field order
   and scan for illegal transitions in the d2v file.  If you are not using a d2v source then adjust
   the examples as necessary to meet your requirments.


NTSC cases:


   1.) NTSC Film, normal source (not anime or cartoon).  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate()


   2.) NTSC Film, anime or cartoon source.  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(mode=1)


   3.) NTSC Hybrid, using blend decimation on video sections (not anime or cartoon).  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(hybrid=1)


   4.) NTSC Hybrid, using blend decimation on video sectons, anime or cartoon source.  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(mode=1,hybrid=1)


   5.) NTSC Hybrid, using vfr via mkv (not anime or cartoon).  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(mode=3,hybrid=2,vfrDec=0,mkvOut="mkv-timecodesfile.txt")


   6.) NTSC Hybrid, using vfr via mkv, anime or cartoon source.  One pass.

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(mode=3,hybrid=2,vfrDec=1,mkvOut="mkv-timecodesfile.txt")


   7.) NTSC, two pass (enables use of conCycleTP parameter) mkv vfr for hybrid source.

         First pass:

             mpeg2source("c:\oursource.d2v")
             tfm(d2v="c:\oursource.d2v",output="matches.txt")
             tdecimate(mode=4,output="metrics.txt")

         Second pass (not anime or cartoon):

             mpeg2source("c:\oursource.d2v")
             tfm(d2v="c:\oursource.d2v",input="matches.txt")
             tdecimate(mode=5,hybrid=2,vfrDec=0,input="metrics.txt",tfmIn="matches.txt",mkvOut="mkv-timecodesfile.txt")

         Second pass (anime or cartoon):

             mpeg2source("c:\oursource.d2v")
             tfm(d2v="c:\oursource.d2v",input="matches.txt")
             tdecimate(mode=5,hybrid=2,vfrDec=1,input="metrics.txt",tfmIn="matches.txt",mkvOut="mkv-timecodesfile.txt")



PAL Cases:


   1.) PAL, no decimation (just field matching)
          
          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")


   2.) PAL, decimate 1 in 25 (most similar)

          mpeg2source("c:\oursource.d2v")
          tfm(d2v="c:\oursource.d2v")
          tdecimate(cycle=25)



contact:   forum.doom9.org  nick = tritical  or  email:  kes25c@mizzou.edu
__________________
powered by Google Translator
Motenai Yoda is offline   Reply With Quote
Old 17th January 2020, 19:56   #8  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by sonic41592 View Post
I tried using QTGMC for the video, but the 24 fps progressive sections are ran at 59.94 fps, which makes them play sped up compared to the telecine and interlaced sections.
That's because you used MakeMKV to 'decrypt' it. Do a proper decrypt and try again. Nothing gets speeded up.
Quote:
I'm planning on upscaling the series with waifu2x
Upscale using NNEDI3_RPOW2 instead. Much faster.

Last edited by manono; 17th January 2020 at 19:58.
manono is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.