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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th September 2022, 05:59   #1541  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Sorry for late answer, I did not see your post, not been about much lately.

I think requestLinear would be best placed AFTER RoboCrop(),
you probably get the frame not cached thingy because RoboCrop() by default samples 40 frames, spread evenly throughout the source clip,
and requestLinear might need to cache entire clip for it to work correctly.
After its pre-scan, RoboCrop delivers cropped frames as per normal.

EDIT:
I did experience some problems with DGSource some months ago [dont know if same prob in current DGSource, updated several times since],
where RoboCrop failed to find good border, and I examined RoboCrop() Debug Info output to DebugView to view 1st frame which showed no border at all.
I then inserted "Return Last" immediately after DGSource [ie no RoboCrop], reloaded clip into VDub2, and jumped to that no-border frame.
Was a full-frame multi-colored mess due to DGS not decoding frame properley at that frame entry point. Repeat with jump to 10 or so frames before the offending frame,
then stepping forward, shows that there is no decode problem, only when decode from problem frame, ie not a source clip problem, is DGS x264 decode problem [was in MKV].

Maybe its fixed now in DGS [EDIT: DGS == DGSource, DGIndexNV source filter], I dont know.

Is it similar problem that you are having, I think I just did manual crop on clips exibiting that [fairly uncommon, maybe 1 in 20 or 30 clips] prob.

EDIT: You might be able to encourage frame decode failure [for experiment] by changing RoboCrop(SAMPLES=Src.FrameCount/50) [about 2%] on a clip of
200,000 frames or so. Maybe prob happens only on clips encoded by a certain encoder, or on all clips, dont know.

EDIT: eg
Code:
DGSource("D:\Source.dgi")
FC      = FrameCount
PERCENT = 2.0 / 100.0  # 2.0 %
SAMPLES = Round(FC*PERCENT)
THRESH  = -40 # -40 Default with AutoThresh Prescan, use eg THRESH=56 to set Explicit Threshold without AutoThresh prescan before border detect scan [ie faster but not as good if dodgy levels clip].
RT_DebugF("FRAMECOUNT=%d %.3f%% SAMPLES=%d THRESH=%f",FC,PERCENT,SAMPLES,THRESH)
Return RoboCrop(Samples=SAMPLES,Thresh=THRESH,Debug=True)
DebugVew
Code:
00006340    0.48317650  RT_DebugF: FRAMECOUNT=150401 0.020% SAMPLES=3008 THRESH=-40.000000

00006342    0.54735380  RoboCrop: v1.13 - 07 Feb 2020 - By StainlessS
00006343    0.54740667  Input: Width=1920 Height=1080 FrameCount=150401
00006345    0.54753429  Thresh set to user supplied -40.00
00006346    0.54755449  Thresh -40.00 recognised as DEFAULT AUTOTHRESH
00006347    0.54757363  Potential Auto Credits Skip Start@5%=7520 End @90%=135360 : Range=127841
00006348    0.54759288  Skip Start(7520) and End(135360) : Range=127841
00006350    0.54766637  Samples=3008 Thresh=-40.000 Laced=True Matrix=3
00006351    0.54774839  WMod=4 HMod=4 {Colorspace/Laced Restricted XMod=2 YMod=4}
00006352    0.54783821  RLBT=15 Ignore=0.400 Baffle=4
00006353    0.54789507  ScaleAutoThreshRGB=Yes ScaleAutoThreshYUV=No
00006354    0.54799873  CropMode=2(CropMore) Blank=No Align=Yes Show=No Log=No
00006355    0.54801899  Atm=4.000 SampStart=7520 SampEnd=135360 SampRange=127841
00006356    0.54803818  LeftAdd=0 TopAdd=0 RightAdd=0 BotAdd=0
00006357    0.54805768  LeftSkip=0 TopSkip=0 RightSkip=0 BotSkip=0
00006358    0.54807669  ScanPerc=49.000000
00006359    0.54809052  Prefix='ROBOCROP_'
00006361    0.62823510  AutoThresh   1) [  7520] YPlaneMin = 16 (16)
00006362    0.69479620  AutoThresh   2) [  7563] YPlaneMin = 16 (16)
00006363    0.75452262  AutoThresh   3) [  7605] YPlaneMin = 16 (16)

# ...

00009366    126.16909790    AutoThresh 3006) [135275] YPlaneMin = 16 (14)
00009367    126.23580170    AutoThresh 3007) [135317] YPlaneMin = 16 (14)
00009368    126.29372406    AutoThresh 3008) [135360] YPlaneMin = 16 (14)

# ...

00009370    126.29382324    YPlaneMin=14 : Automatic set Thresh=54.000
00002917    122.82308197    Top   1) [  7520]  AveY= 92.22  Y1= 20
00009373    126.36152649    Bot   1) [  7520]  AveY= 81.78  Y2=1059
00009374    126.36154938    Lft   1) [  7520]  AveY= 90.43  X1=  1
00009375    126.36158752    Rgt   1) [  7520]  AveY= 70.37  X2=1919
00009376    130.46037292    Lft 100) [ 11729]  AveY= 77.79  X1=  0
00009378    249.04609680    Active Frames (where image coords first found) = 2
00009379    249.04611206    Sampled ImageEdge:  X1=0  Y1=20  X2=1919(W=1920,0)  Y2=1059(H=1040,-20)
00009381    249.04624939    Crop(ModW/H):  X =  0   Y = 20   W =1920(0)   H =1040(-20)
00009382    249.04632568    Input: Width=1920 Height=1080
00009383    249.04640198    Crop(0,20,1920,1040)
00009384    249.04647827    Crop(0,20,0,-20)
00009385    249.04650879    Constructor Scan Total Time=248.555 secs
Border Edge
Sample Number
Frame Number
Scanline_H/V Luma Y
Coord
Above, Top, Bot, and Right borders found on first sample frame, but Left edge not found until 100'th sample,
prior to 100'th sample, best Left border was at X coord 1, at 100'th sample Left X coord found to be 0.
The test clip above did NOT reveal any bad decode in current DGS.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th September 2022 at 19:42.
StainlessS is offline   Reply With Quote
Old 22nd September 2022, 02:09   #1542  |  Link
Blankmedia
Registered User
 
Join Date: Oct 2011
Location: Dans le nord
Posts: 65
Quote:
Originally Posted by StainlessS View Post
Sorry for late answer, I did not see your post, not been about much lately.

I think requestLinear would be best placed AFTER RoboCrop(),
you probably get the frame not cached thingy because RoboCrop() by default samples 40 frames, spread evenly throughout the source clip,
and requestLinear might need to cache entire clip for it to work correctly.
After its pre-scan, RoboCrop delivers cropped frames as per normal.

EDIT:
I did experience some problems with DGSource some months ago [...]
Thanks, I took your advice, I even pushed robocrop in a second ,single threaded to be sure, script (now 3 part).

I swish d2vsource to lsmash to see if the problem repeated, and it did.

So Robocrop is alright! (I think)

PHP Code:
ClearAutoloadDirs()
#~ AddAutoloadDir("D:\A encoder\avs_simpsons_plugin")
AddAutoloadDir("D:\A encoder\simpsons s02_enc\plugins")
AddAutoloadDir("D:\A encoder\simpsons s02_enc\plugins\SMDegrain v3.5.5d")
# SetMemoryMax(8192*2)
SetMemoryMax(12288)
SetCacheMode(0)

# chemin = "D:\A encoder\simps_s02_60FPSv2\e01\Simpsons_S02E01.d2v"
# chemin = "__CHEMIND2V__"

# d2vsource(chemin, idct=5)

chemin "__CHEMIN__"
LSMASHSource_LWLibavVideoSource(source=chemin)

# RequestLinear(clim=100)
# RequestLinear(rlim=50, clim=100, elim=25)
# RequestLinear(rlim=60, clim=100, elim=40)
# RequestLinear(rlim=60, clim=200, elim=32)
RequestLinear(rlim=60clim=30elim=8)

Convertbits(16)
# QTGMCp(Preset="Very Slow", Nnsize=3, NNeurons=3, EdiMode="BWDIF+NNEDI3", TR2=3, FPSDivisor=2, ShutterBlur=2, ShutterAngleSrc=180, ShutterAngleOut=180, SBlurLimit=8, SourceMatch = 3, Lossless=2)
QTGMC(Preset="Very Slow"Nnsize=3NNeurons=3EdiMode="BWDIF+NNEDI3"TR2=3FPSDivisor=2ShutterBlur=2ShutterAngleSrc=180ShutterAngleOut=180SBlurLimit=8SourceMatch 3Lossless=2)

TDecimate(Mode=1)
santiag().yahr3()

### Derainbow ###
masklisse ex_median("IQM").blur(0.25).Removegrain(17).Flatmask(lo=4,MSR=80,scale=8).ex_inflate(2).Removegrain(7).Removegrain(17)    #.maa2().ex_median("STWM") #.ex_expand(1,"disk").ex_inpand(1,"disk")#.mt_binarize(threshold=25).ex_smooth(2,sharp=true)
masklisse masklisse.ex_Expand(2"disk").ex_median("STWM")
# ~ return ex_adddiff(masklisse.converttoyuv420(), dif=False)

MT_Merge(last ChubbyRain3(),masklisse,Luma=True)
MT_Merge(last DFMDeRainbow(maskthresh=10mc=Falseuse_Flux5framesT=False),masklisse,Luma=True)


### Adjust Color ###
MergeChroma(aWarpSharp2(Depth=10,chroma=6))



# debut = round(59.940/23.976*9000)
# fin = round(59.940/23.976*12000)
# debut = round(29.970/23.976*9000)
# fin = round(29.970/23.976*12000)
# debut = round(9000)
# fin = round(12000)
# trim(debut, fin)
# trim(0,200)
# trim(0,1000)
# Prefetch(12,8) # 
# Prefetch(4,8) # 2.4
# Prefetch(8,8) # 2.353
# Prefetch(4,12) # 2.197
Prefetch(2,8#  2.146, 2.307 lsmash 
The error showed up at somepoint, I think there's something in QTGMCp trying to suck memory and maybe accessing frames in some weird place. I don't know anything so people shouldn't rely on this. But switching to QTGMC removed the problem and memory usage is way lower.

Speed was better at first with QTGMCp, but it fills the memory and it gets lower speed over time.

I'll ask about this in Dogway's thread, but first I'll make some tests to be sure and better orient the discussion.
Blankmedia is offline   Reply With Quote
Old 29th September 2022, 19:08   #1543  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
EDIT: Current Pinterf mod TIVTC, Both x64 & x86 versions.

Presume this is some kind of diff overflow bug in FieldDiff(),

Code:
#WhateverSource(...)
OPT=4 # (default) Auto
#OPT=0 # Use C routines
FieldDiff(debug=true,display=true,opt=OPT)
return last
Similar to both display and DebugView, thoughout video clip.


OPT=4 (Default)
Code:
00007315    3.68521953  FieldDiff:  Frame = 14233  Diff = -207589436161 (sad)
00007316    3.73933315  FieldDiff:  Frame = 14234  Diff = -207589439628 (sad)
00007317    3.76845598  FieldDiff:  Frame = 14235  Diff = -207589438673 (sad)
00007318    3.81965804  FieldDiff:  Frame = 14236  Diff = -207589375022 (sad)
00007319    3.85039353  FieldDiff:  Frame = 14237  Diff = -207589400222 (sad)
00007320    3.88973689  FieldDiff:  Frame = 14238  Diff = -207589383803 (sad)
00007321    3.93053317  FieldDiff:  Frame = 14239  Diff = -207589353349 (sad)
00007322    3.97270870  FieldDiff:  Frame = 14240  Diff = -207589428124 (sad)
00007323    4.05432177  FieldDiff:  Frame = 14241  Diff = -207589397993 (sad)
00007324    4.05959177  FieldDiff:  Frame = 14242  Diff = -207589429589 (sad)
00007325    4.08584976  FieldDiff:  Frame = 14243  Diff = -207589433196 (sad)
OPT=0 # C
Code:
00000093    12.88996887 FieldDiff:  Frame = 14233  Diff = -412316210604 (sad)
00000094    12.89195728 FieldDiff:  Frame = 14234  Diff = -412316214071 (sad)
00000095    12.89433861 FieldDiff:  Frame = 14235  Diff = -412316213116 (sad)
00000096    12.89671803 FieldDiff:  Frame = 14236  Diff = -412316149465 (sad)
00000097    12.89924335 FieldDiff:  Frame = 14237  Diff = -412316174664 (sad)
00000098    12.90135288 FieldDiff:  Frame = 14238  Diff = -412316158245 (sad)
00000099    12.90339375 FieldDiff:  Frame = 14239  Diff = -412316127792 (sad)
00000100    12.90548992 FieldDiff:  Frame = 14240  Diff = -412316202567 (sad)
00000101    12.90757942 FieldDiff:  Frame = 14241  Diff = -412316172435 (sad)
00000102    12.90983963 FieldDiff:  Frame = 14242  Diff = -412316204032 (sad)
00000103    12.91174793 FieldDiff:  Frame = 14243  Diff = -412316207639 (sad)
Above SAD.
[sse=true, = similar results (sum of squared errors, I think)].
Also different result for auto or C.

EDIT: PAL DVD source.
720 * 576 * 255 = only 105,753,600.

EDIT: Perhaps not limited to 0, after subtract of noise threshold. [avoid -ve addition to unsigned SAD]
Something like
Abs(a-b) - nt instead of Max(Abs(a-b) - nt, 0), just guessing.
Code:
FieldDiff(int nt, bool chroma, bool display, bool debug, bool sse, int opt)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th September 2022 at 09:42.
StainlessS is offline   Reply With Quote
Old 30th September 2022, 02:24   #1544  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
Quote:
Originally Posted by StainlessS View Post
EDIT: Current Pinterf mod TIVTC, Both x64 & x86 versions.

Presume this is some kind of diff overflow bug in FieldDiff(),

Code:
#WhateverSource(...)
OPT=4 # (default) Auto
#OPT=0 # Use C routines
FieldDiff(debug=true,display=true,opt=OPT)
return last
Similar to both display and DebugView, thoughout video clip.


OPT=4 (Default)
Code:
00007315    3.68521953  FieldDiff:  Frame = 14233  Diff = -207589436161 (sad)
00007316    3.73933315  FieldDiff:  Frame = 14234  Diff = -207589439628 (sad)
00007317    3.76845598  FieldDiff:  Frame = 14235  Diff = -207589438673 (sad)
00007318    3.81965804  FieldDiff:  Frame = 14236  Diff = -207589375022 (sad)
00007319    3.85039353  FieldDiff:  Frame = 14237  Diff = -207589400222 (sad)
00007320    3.88973689  FieldDiff:  Frame = 14238  Diff = -207589383803 (sad)
00007321    3.93053317  FieldDiff:  Frame = 14239  Diff = -207589353349 (sad)
00007322    3.97270870  FieldDiff:  Frame = 14240  Diff = -207589428124 (sad)
00007323    4.05432177  FieldDiff:  Frame = 14241  Diff = -207589397993 (sad)
00007324    4.05959177  FieldDiff:  Frame = 14242  Diff = -207589429589 (sad)
00007325    4.08584976  FieldDiff:  Frame = 14243  Diff = -207589433196 (sad)
OPT=0 # C
Code:
00000093    12.88996887 FieldDiff:  Frame = 14233  Diff = -412316210604 (sad)
00000094    12.89195728 FieldDiff:  Frame = 14234  Diff = -412316214071 (sad)
00000095    12.89433861 FieldDiff:  Frame = 14235  Diff = -412316213116 (sad)
00000096    12.89671803 FieldDiff:  Frame = 14236  Diff = -412316149465 (sad)
00000097    12.89924335 FieldDiff:  Frame = 14237  Diff = -412316174664 (sad)
00000098    12.90135288 FieldDiff:  Frame = 14238  Diff = -412316158245 (sad)
00000099    12.90339375 FieldDiff:  Frame = 14239  Diff = -412316127792 (sad)
00000100    12.90548992 FieldDiff:  Frame = 14240  Diff = -412316202567 (sad)
00000101    12.90757942 FieldDiff:  Frame = 14241  Diff = -412316172435 (sad)
00000102    12.90983963 FieldDiff:  Frame = 14242  Diff = -412316204032 (sad)
00000103    12.91174793 FieldDiff:  Frame = 14243  Diff = -412316207639 (sad)
Above SAD.
[sse=true, = similar results (sum of squared errors, I think)].
Also different result for auto or C.

EDIT: PAL DVD source.
720 * 576 * 255 = only 105,753,600.

EDIT: Perhaps not limited to 0, after subtract of noise threshold. [avoid -ve addition to SAD]
Something like
Abs(a-b) - nt instead of Max(Abs(a-b) - nt, 0), just guessing.
Code:
FieldDiff(int nt, bool chroma, bool display, bool debug, bool sse, int opt)
Can you report to him here?? Cause he access to doom9 rarely
kedautinh12 is offline   Reply With Quote
Old 3rd October 2022, 10:55   #1545  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Hello, I have some 30p streams which contain a mix of 1:1 (30fps) and 1:1:1:2 (24fps) cadences inside them. Is it possible to use TDecimate to convert these into a 60p stream containing 2:2 (30fps) and 3:2 (24fps)?

The closest I can get is 2:2 and 3:3:2:2 with this bodge:

Code:
ChangeFPS(120000,1001)  
TDecimate(mode=1,hybrid=0,cycle=4,cycleR=2,vidThresh=1.1,display=true)
Test clip: https://drive.google.com/file/d/10pq...61sufzIy-/view

The first 8 seconds are 1:1:1:2 followed by 5 seconds of 1:1. If you are using MPC-HC you can step through each frame with ctrl+arrows to count the cadence manually.
flossy_cake is offline   Reply With Quote
Old 3rd October 2022, 22:24   #1546  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 1,048
Quote:
Originally Posted by flossy_cake View Post
Hello, I have some 30p streams which contain a mix of 1:1 (30fps) and 1:1:1:2 (24fps) cadences inside them. Is it possible to use TDecimate to convert these into a 60p stream
TDecimate is for reducing your frame rate, not increasing it.
__________________
I ask unusual questions but always give proper thanks to those who give correct and useful answers.
Katie Boundary is offline   Reply With Quote
Old 3rd October 2022, 23:09   #1547  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
not increasing it
I think he/she knows that.
Is increasing to 119.880 FPS [NTSC weird 120fps], then decimating to NTSC 60fps.
[intention to get smoother playing result without losing any source frames, I think, something like that.]

His/her other thread:- https://forum.doom9.org/showthread.php?t=184448
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 4th October 2022, 17:46   #1548  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by flossy_cake View Post
Hello, I have some 30p streams which contain a mix of 1:1 (30fps) and 1:1:1:2 (24fps) cadences inside them. Is it possible to use TDecimate to convert these into a 60p stream containing 2:2 (30fps) and 3:2 (24fps)?
Are there a lot of video sections? I ask, because the only way I could get the 3:2 cadence was to do it the hard way (samples downscaled to reduce the file size).

Code:
Trim(0,274).TDecimate().ChangeFPS(60000,1001) ++ \
Trim(275,0).ChangeFPS(60000,1001)
CFR.mkv

Variable frame rate easier?

Code:
# Analysis pass (comment out any filters after TDecimate so they don't run)
# TFM(Output=FTFM()).TDecimate(Mode=4, Hybrid=2, Output=FTDec())

# Encoding pass (uncomment any filters after TDecimate)
TFM(Input=FTFM()).TDecimate(Mode=5, Hybrid=2, Input=FTDec(), TFMIn=FTFM(), mkvOut=FTC())
Sample x264 command line:
x264.exe --level 4.1 --preset slow --tune film --crf 18.0 --tcfile-in "D:\VFR_TIMES.txt" --output "D:\VFR.mkv" "D:\VFR.avs"

VFR.mkv

Functions for automatic file name creation based on the script name.
Creates files in the script folder. If no script exists (ie before saving a script when using AVSPMod) they're configured to save to the root of drive D, but without using the script name (obviously).

Code:
# ===============================================================================

function FTFM()  {

Try{
ScriptName = ScriptFile()
EndLength = FindStr(LCase(ScriptName), ".avs") - 1
FileName = ((EndLength > 0) ? LeftStr(ScriptName, EndLength) : ScriptName) + "_TFM.txt" }
catch(err){ FileName = "D:\_TFM.txt" }

return FileName  }

# -------------------------------------------------------------------------------

function FTDec()  {

Try{
ScriptName = ScriptFile()
EndLength = FindStr(LCase(ScriptName), ".avs") - 1
FileName = ((EndLength > 0) ? LeftStr(ScriptName, EndLength) : ScriptName) + "_TDecimate.txt" }
catch(err){ FileName = "D:\_TDecimate.txt" }

return FileName  }

# -------------------------------------------------------------------------------

function FTC()  {

Try{
ScriptName = ScriptFile()
EndLength = FindStr(LCase(ScriptName), ".avs") - 1
FileName = ((EndLength > 0) ? LeftStr(ScriptName, EndLength) : ScriptName) + "_TIMES.txt" }
catch(err){ FileName = "D:\_TIMES.txt" }

return FileName  }

# ===============================================================================

Last edited by hello_hello; 4th October 2022 at 17:57.
hello_hello is offline   Reply With Quote
Old 5th October 2022, 00:27   #1549  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Thank you, the result of VFR.mkv is perfect

But is there a reason why TFM() needs to be used if it's not interlaced?
flossy_cake is offline   Reply With Quote
Old 5th October 2022, 03:06   #1550  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
At one stage TDecimate required a TFM metrics file for mode=5, but the help file now says:

As of version 0.9.11.8 of TDecimate, an input and tfmIn file are no longer
required for mode 5. If an input file is not specified then a value of
ULLONG_MAX-1 (the maximum value tdecimate has) is assigned to all metrics.
Likewise, if a tfmIn file is not specified then all matches are assigned as 'c',
not combed, and not a d2v duplicate.


I'm not sure I fully understand that though. Including TFM shouldn't do any harm.
hello_hello is offline   Reply With Quote
Old 5th October 2022, 10:54   #1551  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Quote:
Originally Posted by hello_hello View Post
Variable frame rate easier?

Code:
# Analysis pass (comment out any filters after TDecimate so they don't run)
# TFM(Output=FTFM()).TDecimate(Mode=4, Hybrid=2, Output=FTDec())

# Encoding pass (uncomment any filters after TDecimate)
TFM(Input=FTFM()).TDecimate(Mode=5, Hybrid=2, Input=FTDec(), TFMIn=FTFM(), mkvOut=FTC())
After some faffing about it seems for my purposes I can just go:

Code:
TDecimate(mode=3, hybrid=2, viddetect=2, cycle=5, cycleR=1, mkvOut="TIMES.txt")
But TDecimate requires "linear access" for mode3 and won't let me call it from ffmpeg. Maybe Virtualdub can manage it?

Anyway I did manage to get ffmpeg crunching with this:

Code:
ffmpeg -i "VFRpass1.avs" -threads 4 -f null NUL && ffmpeg -i "VFRpass2.avs" -threads 4 -f null NUL

VFRpass1.avs:
LWLibavVideoSource(source="1112-11.mkv", cache=false)
TDecimate(mode=4, hybrid=2, viddetect=2, cycle=5, cycleR=1, output="FTDEC.txt")

VFRpass2.avs:
LWLibavVideoSource(source="1112-11.mkv", cache=false)
TDecimate(mode=5, hybrid=2, viddetect=2, cycle=5, cycleR=1, input="FTDEC.txt", mkvOut="TIMES.txt")
Skipping the TFM() step doubles my framerate from 150fps to 300fps, and it seems to be working -- the TIMES.txt file it generates is identical. The viddetect=2 is required though. Seems to be something buggy going on with that.

ffmpeg says it supports vfr encoding with "-vsync vfr" but I couldn't get it to work. ffmpeg doesn't seem to support matroska timecode files either but hoping someone can correct me on that.

Last edited by flossy_cake; 5th October 2022 at 11:06.
flossy_cake is offline   Reply With Quote
Old 5th October 2022, 12:21   #1552  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by flossy_cake View Post
Skipping the TFM() step doubles my framerate from 150fps to 300fps, and it seems to be working -- the TIMES.txt file it generates is identical. The viddetect=2 is required though. Seems to be something buggy going on with that.
What happens without viddetect=2?

I'm hopeless with ffmpeg so hopefully someone else can help you there. Although....

The first line of the timecodes file should be
# timecode format v1

This is just a guess, but try changing it to
# timestamp format v1
to see if ffmpeg will play with it then.

Last edited by hello_hello; 5th October 2022 at 12:41.
hello_hello is offline   Reply With Quote
Old 5th October 2022, 13:25   #1553  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Quote:
Originally Posted by hello_hello View Post
What happens without viddetect=2?
Nevermind I was mistaken about that. The default is 3 which requires both TFM matches and TDecimate metrics to recognise it as "video". Since I never used TFM it would always fail this condition and that's why the stairs section wouldn't switch to blend. And in your example it didn't fail since you were feeding it TFM matches via the txt file.

Quote:
Originally Posted by hello_hello View Post
This is just a guess, but try changing it to
# timestamp format v1
to see if ffmpeg will play with it then.
Problem is I can't even find any ffmpeg argument relating to mkv timestampcode files. The ffmpeg GUI XMediaRecode also has no such option and no control over framerate mode. Seems like ffmpeg doesn't support it at all but hoping I'm mistaken.
flossy_cake is offline   Reply With Quote
Old 6th October 2022, 00:57   #1554  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
If you're not married to XMediaRecode but want to use a GUI, try MeGUI. You can just add the timecodes file in the x264 encoder configuration. https://i.ibb.co/QvhkcMG/1.png
I still don't know if x265 has a VFR mode and MeGUI's x265 encoder configuration is pretty basic anyway.

I'm not sure I understand the "linear access" problem you mentioned earlier, but the TIVTC plugin has a RequestLinear() function if that's any help.
hello_hello is offline   Reply With Quote
Old 6th October 2022, 03:52   #1555  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Quote:
Originally Posted by hello_hello View Post

Code:
# Analysis pass (comment out any filters after TDecimate so they don't run)
# TFM(Output=FTFM()).TDecimate(Mode=4, Hybrid=2, Output=FTDec())

# Encoding pass (uncomment any filters after TDecimate)
TFM(Input=FTFM()).TDecimate(Mode=5, Hybrid=2, Input=FTDec(), TFMIn=FTFM(), mkvOut=FTC())
Sample x264 command line:
x264.exe --level 4.1 --preset slow --tune film --crf 18.0 --tcfile-in "D:\VFR_TIMES.txt" --output "D:\VFR.mkv" "D:\VFR.avs"
I'm trying to reproduce this and am totally confused, because the file VFR_TIMES.txt won't exist until after the "encoding pass" in your VFR.avs is complete, so I'm not sure how you are feeding that as an input to x264.exe if it hasn't been created yet.

If you wouldn't mind, could you split it up into:

VFR pass1.avs
VFR pass2.avs
Inputfile for x264.avs

edit: also this is my VFR_TIMES.txt, it seems correct though as I've stepped through the video and identified frame 219 is the last of the 24p section

Code:
# timecode format v1
Assume 29.970030
# TDecimate v1.0.8 by tritical
# Mode 5 - Auto-generated mkv timecodes file
0,219,23.976024
# vfr stats:  51.02% film  48.98% video
# vfr stats:  275 - film  264 - video  539 - total
# vfr stats:  longest vid section - 0 frames
# vfr stats:  # of detected vid sections - 0

Last edited by flossy_cake; 6th October 2022 at 04:05.
flossy_cake is offline   Reply With Quote
Old 6th October 2022, 04:17   #1556  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Quote:
Originally Posted by hello_hello View Post
I'm not sure I understand the "linear access" problem you mentioned earlier, but the TIVTC plugin has a RequestLinear() function if that's any help.
It works!

Code:
CreateTimestampFile.avs:

	file = "clips\1112-11.mkv"	
	LWLibavVideoSource(source=file, cache=false)
	TDecimate(mode=3, hybrid=2, viddetect=2, cycle=5, cycleR=1, mkvOut="TIMES.txt")
	RequestLinear()

To run it from ffmpeg:

	ffmpeg -i "CreateTimestampFile.avs" -threads 4 -f null NUL
So now I have this TIMES.txt file with the required information, I just need to figure out how to use it to encode the new VFR file.

btw I tried mkvtoolnix and handbrake without success but I'm probably doing something wrong, just can't figure out what.

I'm still not clear on what the input file is when encoding the new VFR file -- is it the original 1112-11.mkv or the TDecimated version of it?

Last edited by flossy_cake; 6th October 2022 at 04:23.
flossy_cake is offline   Reply With Quote
Old 6th October 2022, 04:18   #1557  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by flossy_cake View Post
I'm trying to reproduce this and am totally confused, because the file VFR_TIMES.txt won't exist until after the "encoding pass" in your VFR.avs is complete, so I'm not sure how you are feeding that as an input to x264.exe if it hasn't been created yet.

If you wouldn't mind, could you split it up into:

VFR pass1.avs
VFR pass2.avs
Inputfile for x264.avs
The timecodes file should be created as soon as you open the 2nd pass script. The 2nd pass doesn't need to be run as such, just opened, and the timecodes file is created in an instant (assuming the 1st pass files exist).

When I'm doing a bunch of VFR encodes I often add the same scripts to MeGUI twice, once as an analysis pass and then again as an encoding job, modifying MeGUI's encoder configuration to adjust the name of the timecodes file each time if need be. The encoding pass would be commented out at that stage.

Once all the analysis passes have finished I open the scripts and comment out the analysis pass and uncomment the encoding pass, then let MeGUI run the encoding jobs. As soon as MeGUI opens each script for encoding it's timecodes file is created and as long as the name of the timecodes file added to the x264 command line matches, the encodes run normally.

If you're running the encodes via the command line yourself or using a batch file etc, you should still be able to do much the same thing.

Each script can use the same name for the timecodes file, if you prefer, because as soon as you open the 2nd pass script the existing timecodes file will be over-written, but I tend to give them unique names when encoding a bunch of scripts.

PS. The first pass files are similar. As soon as you open the 1st pass script any existing metrics files with the same names will be over-written with blank ones and you'll have to run the analysis pass again, so once it's run, be careful about opening the 1st pass script again.

Last edited by hello_hello; 6th October 2022 at 05:07.
hello_hello is offline   Reply With Quote
Old 6th October 2022, 04:29   #1558  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by flossy_cake View Post
So now I have this TIMES.txt file with the required information, I just need to figure out how to use it to encode a the new VFR file.

btw I tried mkvtoolnix and handbrake without success but I'm probably doing something wrong, just can't figure out what.
If you're VFR encoding with x264 and it's configured to write the encoded video to an MKV you don't need to add the timecodes file when muxing. It'll be created as VFR.

If you're encoding at a CFR (and probably when x264 is writing to a raw AVC stream) you'd add the timecodes to MKVToolNix under the Timecodes tab, assuming it hasn't changed (I'm using a pretty old version as I mostly use XP). Make sure the video track is the one selected when you add it.

https://i.ibb.co/WKC3fh2/Clipboard01.jpg

I don't think Handbrake will use a timecodes file for encoding. Does it accept Avisynth scripts as the input video anyway?

Quote:
Originally Posted by flossy_cake View Post
I'm still not clear on what the input file is -- the original 1112-11.mkv or the TDecimated version of it?
The original for encoding and the decimated/re-encoded version for muxing.

Last edited by hello_hello; 6th October 2022 at 05:17.
hello_hello is offline   Reply With Quote
Old 6th October 2022, 04:37   #1559  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by flossy_cake View Post
edit: also this is my VFR_TIMES.txt, it seems correct though as I've stepped through the video and identified frame 219 is the last of the 24p section

Code:
# timecode format v1
Assume 29.970030
# TDecimate v1.0.8 by tritical
# Mode 5 - Auto-generated mkv timecodes file
0,219,23.976024
# vfr stats:  51.02% film  48.98% video
# vfr stats:  275 - film  264 - video  539 - total
# vfr stats:  longest vid section - 0 frames
# vfr stats:  # of detected vid sections - 0
As long as you mean frame 219 in the output file it looks about right (unfortunately I've deleted the one I created yesterday so I can't compare them).

Edit: Here's the timecodes file I extracted from VFR.mkv. It's extracted as version 2 timecodes, but line #222 seems to be where it changes from 42ms between timestamps to 33ms. Subtract two from that because the first line isn't a timecode and the first frame is zero rather than one, and the video section starts on frame #220 (I think that's right).

VFR_track1__eng_.tc.txt

Last edited by hello_hello; 6th October 2022 at 05:41.
hello_hello is offline   Reply With Quote
Old 6th October 2022, 05:25   #1560  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Quote:
Originally Posted by hello_hello View Post
The timecodes file should be created as soon as you open the 2nd pass script
Oh you're right it does! I was confused because I was using mode3 to generate the TIMES.txt file, and mode3 doesn't finish creating the file until the video has finished playing in MPC-HC, or finished processing in ffmpeg.

But in your case mode5 seems to be taking the TFM metrics and immediately generating the TIMES.txt file from it.

I got your code working on my end and the result is good. I tested the VFR file on my set top box @ 60hz and to my surprise it does actually manage it correctly, although there is a slight pause on the rate change.

I'm seeing some comments that VFR may not be a good idea as many devices don't handle it correctly. Given those comments I'm leaning towards the 60p CFR solution again but there doesn't seem to be a way to automate it.

Last edited by flossy_cake; 6th October 2022 at 06:29.
flossy_cake is offline   Reply With Quote
Reply

Tags
tdeint, tivtc

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 19:27.


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