I need to know how to format current_frame variable to pad left to zeroes.
Something like this won't work, also tested a dozen more combinations.
Convert frame 27 to something like 0000027.HTML Code:ScriptClip("""Subtitle(string("current_frame","%05.0f"))""")
edit: I think this can't be done since I saw RT_WriteFile with formatted strings as a feature, belongs to RT_Stats pack.
+ Reply to Thread
Results 1 to 10 of 10
-
Last edited by Dogway; 13th Apr 2015 at 06:47.
-
Remove the quotes around current_frame.
Code:ScriptClip("""Subtitle(string(current_frame,"%07.0f"))""")
-
Thanks jagabo, made it work, slow day
Code:WriteFileIf(last, "Statistics.txt", "YPlaneMin<10", """string(current_frame,"%07.0f")""", """ ":" """, "YPlaneMin")
Last edited by Dogway; 13th Apr 2015 at 06:57.
-
It's been long since I made some heavy avisynth work. I got another question, hopefully not as bland.
I'm making some functions for cleaning film gate frames and black borders from the output of stab() and whatnot (hopefully a release in a few days). For the latter I'm trying to write out a statistics file of a variable within the script, while at the same time using the main script as the clip output. The problem is I can not do both at the same time.
Code:o=last c=somefilter() WriteFileIf(c,""+path+"\FindBlackBorders - Statistics.log", "YPlaneMin<"+string(thr)+" ", """ "CHAPTER00=" ""","FFFormatTime(round((current_frame * 1000) / framerate()))", """ "|" """, "YPlaneMin") o
-
I worked around the above question with WriteFile, but I would like to know regardless if there's a more straight way.
Also I have issues with this simple script:
Code:c=last msk=mt_lut("255") mt_merge(msk,c,msk,luma=true)
Dither_merge16_8() is ok, but doing 16bit work for this sounds like a bit too much? -
It's a bit lighter on my computer. Adding Interleave(c, last).Histogram() provides a hint. It looks like a rounding error where everything below 128 gets shifted up by one unit. Overlay(msk,c,mask=msk) does the same.
Regarding your previous question -- I understand the question. What do you mean by "won't process the WriteFile in the background"?Last edited by jagabo; 14th Apr 2015 at 07:07.
-
Yes, as I suspected a rounding error. Probably the 255-256 thing?
This is a game changer to be honest, I will probably avoid using mt_merge from now on.
About WriteFile what I meant is that I wanted to use WriteFile for a variable within the script, but actually output another variable (not in the chain) as the clip.
As in the example above, WriteFile won't write any file because the output is "o" clip.
What I did to workaround that was to virtually include WriteFile in the thread chain by using mt_merge()
Code:o=last c=somefilter() WriteFileIf(c,""+path+"\FindBlackBorders - Statistics.log", "YPlaneMin<"+string(thr)+" ", """ "CHAPTER00=" ""","FFFormatTime(round((current_frame * 1000) / framerate()))", """ "|" """, "YPlaneMin") mt_merge(c,mt_lut("255"),luma=true)
-
Overlay() has the same problem. I suspect this is the source of the Chroma channels changing in the same way when using Stab(). It's especially bad with Stab() because frames that are shifted change colors, frames that aren't shifted don't change color. You end up with flickering colors.
Yes, you are right. If the output isn't used the chain isn't executed. Normally we think of filters passing data from the top of the script (input file) to the bottom (output). But AviSynth actually works the other way, it pulls data from the bottom. So any part of the script that isn't output isn't executed. The description of ConditionalFilter() explains this:
http://avisynth.nl/index.php/ConditionalFilter -
I didn't know about Overlay because I rarely use it, sometimes internal functions are buggy but I didn't expect the same with masktools, I was proved wrong I guess.
What striked me was your comment on Stab() chroma issues, I never realized that. I originally was using Stabilise() a more primitive but astounding plugin, but it had issues with chroma shifting to a green hue (regardless of stabilization success), so I changed it for stab(). I really would like to find a robust stabilization plugin for avisynth. Solutions like Deshaker or other commercial ones involves too much intermediary files and render times.
I thought the nature of the WriteFile filter had a different condition. I know the script is evaluated from bottom, but since WriteFile isn't a clip of any sorts (in nature I mean) I didn't think it had to be included in the chain. Well I worked around it but still wanted to know if there was something I was missing, thanks for the help Jagabo. Let's see what I can come up with the new Stabilization Tools, scriptclip is very very slow.Last edited by Dogway; 14th Apr 2015 at 07:52.
-
seems mt_lut("255") output in tv range will be tv range
and it seems mt_merge assume pc range for mask (or maybe everything), just like Overlay
addCode:ColorYUV(levels="TV->PC")
and Dither_merge16_8 is
Code:Function Dither_merge16_8 (clip src1, clip src2, clip mask, bool "luma", int "y", int "u", int "v") { mask16 = StackVertical (mask, mask) Dither_merge16 (src1, src2, mask16, luma=luma, y=y, u=u, v=v) }
Code:Dither_merge16(msk.Dither_convert_8_to_16,c.Dither_convert_8_to_16,msk.Dither_convert_8_to_16,luma=true).DitherPost(mode=-1)
Last edited by real.finder; 7th Sep 2015 at 07:41.
Similar Threads
-
Variable or Constant Framerate?
By JackDanielZ in forum Video ConversionReplies: 56Last Post: 4th Aug 2015, 07:14 -
VirtualDub with variable frame rates
By Vidude in forum Video ConversionReplies: 9Last Post: 16th Nov 2014, 19:38 -
Is there a way to add a variable to a frame using AVISynth?
By ndjamena in forum RestorationReplies: 6Last Post: 10th Jun 2014, 11:56 -
Are variable keyframes possible?
By x2x3x2 in forum Video ConversionReplies: 15Last Post: 7th Aug 2010, 07:40 -
Need help to set up Variable Bitrate
By spigy in forum Video ConversionReplies: 19Last Post: 16th May 2010, 13:13