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. |
7th December 2022, 20:35 | #1 | Link |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
writefileif and timestamp
Hello, i explain what i wanna do...
I would like to have a txt with timestamp of dark frames from a film. I can't find (or I'm not able to use) the internal function to write the timestamp on a file. I see that exist SHOWTIME(), but i guess it only shows the timestamp on the video. At the moment I've this situation Code:
#Specify the name and location of the output file global filename = "blank_frames.txt" #Specify the threshold that will be considered black (0 = pure black) global blankthreshold=17 src="C:\file.mkv" FFvideosource(src) #framerate global f=framerate(last) #Only look at half the fields (speeds up processing) i=separatefields.selectodd.ConvertToYV12() #Write the frame number i.WriteFileIf( filename, "(AverageLuma(i)<blankthreshold)", "current_frame+1", """ time(" %H:%M:%S") """, append = false) I've tried this function Code:
function timecode (int cf,float fr) #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(fr)/log(10)))+".0f") smpte } |
8th December 2022, 01:31 | #2 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I shall try to helpout tomorrow, bit pissed at the moment.
Love and kisses XXX
__________________
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 ??? |
8th December 2022, 12:04 | #3 | Link |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
Ahem, this morning I wake up and I realized was much simpler than I thought yesterday evening
In the end i finished like this Code:
function timecode (int cf,float fr) #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) ms=((cf/fr)-int(cf/fr))*1000 #smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(fr)/log(10)))+".0f") smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ms,"%03.0f") smpte } I use this function here Code:
#Specify the name and location of the output file global filename = "blank_frames.txt" #Specify the threshold that will be considered black (0 = pure black) global blankthreshold=17 src="C:\file.mkv" FFvideosource(src) #framerate global f=framerate(last) #Only look at half the fields (speeds up processing i=separatefields.selectodd.ConvertToYV12() #Write the timecode using a custom function i.WriteFileIf( filename, "(AverageLuma(i)<blankthreshold)", "timecode(current_frame,f)", append = false) #run Video Analysis on AVSPMOD Thanks for the attention Stainless |
8th December 2022, 12:19 | #4 | Link |
Banana User
Join Date: Sep 2008
Posts: 983
|
Or you can try "Frame2TimeFX(current_frame,f)" instead of "timecode(current_frame,f)".
Frame2TimeFX is function from InpaintDelogo.avsi.
__________________
InpaintDelogo, DoomDelogo, JerkyWEB Fixer, Standalone Faster-Whisper - AI subtitling |
8th December 2022, 17:56 | #6 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Some more stuff, took me ages to find it.
See from here(post #28):- https://forum.doom9.org/showthread.p...03#post1951503 Through to post #40. EDIT: And here:- https://forum.doom9.org/showthread.p...02#post1950602 EDIT: From above 2nd link [dont think your +string(ff,"%0"+string(int(log(fr)/log(10)))+".0f", is quite right {although I aint tried it}] Code:
Function nDigits(Int n) { return Int(Log10(Max(n,1)))+1 } # ssS, Log10 v2.60+ [ Log10(n) = Log(n)/Log(10) ] Code:
Function nDigits(Int n) { return int(Log(Max(n,1))/Log(10))+1 } # ssS, v2.58 Ver$ {eg, Log10(0) = ERROR: Although FrameRate is unlikely to be 0 : Also Log10(1) would result in 0, need add 1 to result ie 1 digit : Log10(10) would result in 1, need add 1 to result ie 2 digits, etc for 100, 1000, 10000 ...} ie, Quote:
Quote:
Code:
smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(Max(fr,1))/log(10))+1)+".0f")
__________________
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; 8th December 2022 at 20:23. |
||
8th December 2022, 21:38 | #7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Some/Most of previous post is total twaddle, [ ]
nDigits does work exactly as intended, HOWEVER, max framenumber part has got to be 1 less than framerate, so the +1 thingy in blue is wrong-ish. but, the original tsp code is also not 100% working proper. Code:
Function showsmpte(int cf,float fr) { #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(fr)/log(10)))+".0f") smpte } Function showsmpte_Mod(int cf,float fr) { #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) Return string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(Max(fr,1))/log(10))+1)+".0f") } For(i=0,9) { FRate = Select(i, 0.5, 0.9, 1.0, 1.1, 9.0, 10.0, 11.0, 99.0, 100.0, 101.0) FrameNo = int(FRate*2) S1 = showsmpte(FrameNo-1,FRate) S2 = showsmpte_Mod(FrameNo-1,FRate) RT_DebugF("%d:%.1f] '%s' : '%s' %s",FrameNo-1,FRate, S1,S2,S1==S2?"SAME":"") S1 = showsmpte(FrameNo,FRate) S2 = showsmpte_Mod(FrameNo,FRate) RT_DebugF("%d:%.1f] '%s' : '%s' %s",FrameNo,FRate, S1,S2,S1==S2?"SAME":"") S1 = showsmpte(FrameNo+1,FRate) S2 = showsmpte_Mod(FrameNo+1,FRate) RT_DebugF("%d:%.1f] '%s' : '%s' %s",FrameNo+1,FRate, S1,S2,S1==S2?"SAME":"") } return MessageClip("Done") Code:
00002427 20:28:02.108 RT_DebugF: 0:0.5] '00:00:00:0' : '00:00:00:0' SAME 00002428 20:28:02.108 RT_DebugF: 1:0.5] '00:00:02:0' : '00:00:02:0' SAME 00002429 20:28:02.108 RT_DebugF: 2:0.5] '00:00:04:0' : '00:00:04:0' SAME 00002430 20:28:02.108 RT_DebugF: 0:0.9] '00:00:00:0' : '00:00:00:0' SAME 00002431 20:28:02.108 RT_DebugF: 1:0.9] '00:00:01:0' : '00:00:01:0' SAME 00002432 20:28:02.108 RT_DebugF: 2:0.9] '00:00:02:0' : '00:00:02:0' SAME 00002433 20:28:02.108 RT_DebugF: 1:1.0] '00:00:01:0' : '00:00:01:0' SAME 00002434 20:28:02.108 RT_DebugF: 2:1.0] '00:00:02:0' : '00:00:02:0' SAME 00002435 20:28:02.108 RT_DebugF: 3:1.0] '00:00:03:0' : '00:00:03:0' SAME 00002436 20:28:02.108 RT_DebugF: 1:1.1] '00:00:00:1' : '00:00:00:1' SAME 00002437 20:28:02.108 RT_DebugF: 2:1.1] '00:00:01:0' : '00:00:01:0' SAME 00002438 20:28:02.108 RT_DebugF: 3:1.1] '00:00:02:0' : '00:00:02:0' SAME 00002439 20:28:02.108 RT_DebugF: 17:9.0] '00:00:01:8' : '00:00:01:8' SAME 00002440 20:28:02.108 RT_DebugF: 18:9.0] '00:00:02:0' : '00:00:02:0' SAME 00002441 20:28:02.108 RT_DebugF: 19:9.0] '00:00:02:1' : '00:00:02:1' SAME 00002442 20:28:02.108 RT_DebugF: 19:10.0] '00:00:01:9' : '00:00:01:09' 00002443 20:28:02.108 RT_DebugF: 20:10.0] '00:00:02:0' : '00:00:02:00' 00002444 20:28:02.108 RT_DebugF: 21:10.0] '00:00:02:1' : '00:00:02:01' 00002445 20:28:02.108 RT_DebugF: 21:11.0] '00:00:01:10' : '00:00:01:10' SAME 00002446 20:28:02.108 RT_DebugF: 22:11.0] '00:00:02:0' : '00:00:02:00' 00002447 20:28:02.108 RT_DebugF: 23:11.0] '00:00:02:1' : '00:00:02:01' 00002448 20:28:02.124 RT_DebugF: 197:99.0] '00:00:01:98' : '00:00:01:98' SAME 00002449 20:28:02.124 RT_DebugF: 198:99.0] '00:00:02:0' : '00:00:02:00' 00002450 20:28:02.124 RT_DebugF: 199:99.0] '00:00:02:1' : '00:00:02:01' 00002451 20:28:02.124 RT_DebugF: 199:100.0] '00:00:01:99' : '00:00:01:099' 00002452 20:28:02.124 RT_DebugF: 200:100.0] '00:00:02:00' : '00:00:02:000' 00002453 20:28:02.124 RT_DebugF: 201:100.0] '00:00:02:01' : '00:00:02:001' 00002454 20:28:02.124 RT_DebugF: 201:101.0] '00:00:01:100' : '00:00:01:100' SAME 00002455 20:28:02.124 RT_DebugF: 202:101.0] '00:00:02:00' : '00:00:02:000' 00002456 20:28:02.124 RT_DebugF: 203:101.0] '00:00:02:01' : '00:00:02:001'
__________________
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; 8th December 2022 at 23:57. |
8th December 2022, 22:03 | #8 | Link | |||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Mod, Code:
Function showsmpte(int cf,float fr) { #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(fr)/log(10)))+".0f") smpte } Function showsmpte_Mod(int cf,float fr) { #cf=current_frame,fr=framerate { hh=int(cf/3600/fr) mm=int((cf-hh*3600*fr)/60/fr) ss=int((cf-hh*3600*fr-mm*60*fr)/fr) ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr)) Return string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(Max(ceil(fr)-1,1))/log(10))+1)+".0f") } For(i=0,9) { FRate = Select(i, 0.5, 0.9, 1.0, 1.1, 9.0, 10.0, 11.0, 99.0, 100.0, 101.0) spFrm = 1.0 / FRate FrameNo = int(FRate*2) S1 = showsmpte(FrameNo-1,FRate) S2 = showsmpte_Mod(FrameNo-1,FRate) RT_DebugF("%6d:%8.1f] %-20s : %-20s %s # (%f)",FrameNo-1,FRate, S1,S2,S1==S2?"SAME":" ",(FrameNo-1)*spFrm) S1 = showsmpte(FrameNo,FRate) S2 = showsmpte_Mod(FrameNo,FRate) RT_DebugF("%6d:%8.1f] %-20s : %-20s %s # (%f)",FrameNo,FRate, S1,S2,S1==S2?"SAME":" ",FrameNo*spFrm) S1 = showsmpte(FrameNo+1,FRate) S2 = showsmpte_Mod(FrameNo+1,FRate) RT_DebugF("%6d:%8.1f] %-20s : %-20s %s # (%f)",FrameNo+1,FRate, S1,S2,S1==S2?"SAME":" ",(FrameNo+1)*spFrm) } return MessageClip("Done") Code:
00002342 22:15:25.818 RT_DebugF: 0: 0.5] 00:00:00:0 : 00:00:00:0 SAME # (0.000000) 00002343 22:15:25.818 RT_DebugF: 1: 0.5] 00:00:02:0 : 00:00:02:0 SAME # (2.000000) 00002344 22:15:25.818 RT_DebugF: 2: 0.5] 00:00:04:0 : 00:00:04:0 SAME # (4.000000) 00002345 22:15:25.818 RT_DebugF: 0: 0.9] 00:00:00:0 : 00:00:00:0 SAME # (0.000000) 00002346 22:15:25.818 RT_DebugF: 1: 0.9] 00:00:01:0 : 00:00:01:0 SAME # (1.111111 ???) 00002347 22:15:25.818 RT_DebugF: 2: 0.9] 00:00:02:0 : 00:00:02:0 SAME # (2.222222 ???) 00002348 22:15:25.818 RT_DebugF: 1: 1.0] 00:00:01:0 : 00:00:01:0 SAME # (1.000000) 00002349 22:15:25.818 RT_DebugF: 2: 1.0] 00:00:02:0 : 00:00:02:0 SAME # (2.000000) 00002350 22:15:25.818 RT_DebugF: 3: 1.0] 00:00:03:0 : 00:00:03:0 SAME # (3.000000) 00002351 22:15:25.818 RT_DebugF: 1: 1.1] 00:00:00:1 : 00:00:00:1 SAME # (0.909091) 00002352 22:15:25.818 RT_DebugF: 2: 1.1] 00:00:01:0 : 00:00:01:0 SAME # (1.818182 ???) 00002353 22:15:25.818 RT_DebugF: 3: 1.1] 00:00:02:0 : 00:00:02:0 SAME # (2.727273 ???) 00002354 22:15:25.818 RT_DebugF: 17: 9.0] 00:00:01:8 : 00:00:01:8 SAME # (1.888889) 00002355 22:15:25.818 RT_DebugF: 18: 9.0] 00:00:02:0 : 00:00:02:0 SAME # (2.000000) 00002356 22:15:25.818 RT_DebugF: 19: 9.0] 00:00:02:1 : 00:00:02:1 SAME # (2.111111) 00002357 22:15:25.818 RT_DebugF: 19: 10.0] 00:00:01:9 : 00:00:01:9 SAME # (1.900000) 00002358 22:15:25.818 RT_DebugF: 20: 10.0] 00:00:02:0 : 00:00:02:0 SAME # (2.000000) 00002359 22:15:25.818 RT_DebugF: 21: 10.0] 00:00:02:1 : 00:00:02:1 SAME # (2.100000) 00002360 22:15:25.818 RT_DebugF: 21: 11.0] 00:00:01:10 : 00:00:01:10 SAME # (1.909091) 00002361 22:15:25.818 RT_DebugF: 22: 11.0] 00:00:02:0 : 00:00:02:00 # (2.000000) 00002362 22:15:25.818 RT_DebugF: 23: 11.0] 00:00:02:1 : 00:00:02:01 # (2.090909) 00002363 22:15:25.818 RT_DebugF: 197: 99.0] 00:00:01:98 : 00:00:01:98 SAME # (1.989899) 00002364 22:15:25.818 RT_DebugF: 198: 99.0] 00:00:02:0 : 00:00:02:00 # (2.000000) 00002365 22:15:25.818 RT_DebugF: 199: 99.0] 00:00:02:1 : 00:00:02:01 # (2.010101) 00002366 22:15:25.818 RT_DebugF: 199: 100.0] 00:00:01:99 : 00:00:01:99 SAME # (1.990000) 00002367 22:15:25.818 RT_DebugF: 200: 100.0] 00:00:02:00 : 00:00:02:00 SAME # (2.000000) 00002368 22:15:25.818 RT_DebugF: 201: 100.0] 00:00:02:01 : 00:00:02:01 SAME # (2.010000) 00002369 22:15:25.818 RT_DebugF: 201: 101.0] 00:00:01:100 : 00:00:01:100 SAME # (1.990099) 00002370 22:15:25.818 RT_DebugF: 202: 101.0] 00:00:02:00 : 00:00:02:000 # (2.000000) 00002371 22:15:25.833 RT_DebugF: 203: 101.0] 00:00:02:01 : 00:00:02:001 # (2.009901) Quote:
Quote:
Above mentioned "Supported drop-frame rates" must be handled especially carefully in ShowSMPTE(), and in at least 64 bit.
__________________
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; 9th December 2022 at 01:00. |
|||
Thread Tools | Search this Thread |
Display Modes | |
|
|