Hover Setting

slideup

សេវាកម្ម : វីដេអូ & រូបថត

កម្មវិធីសំខាន់ៗ ↘︎↘︎↘︎

DaVinci Resolve Expressions (កូដ​ធ្វើចលនា)

ពិភពនៃកន្សោម (expressions) ទាំងនៅក្នុងការកាត់តវីដេអូ និងក្រាហ្វិកចលនា (motion graphics) បានបើកឱកាស និងលទ្ធភាពជាច្រើនរាប់មិនអស់។ នៅក្នុងអត្ថបទនេះ ខ្ញុំនឹងប្រមូលផ្តុំនូវកន្សោមនានាដែលខ្ញុំបានរកឃើញ និងបានសាកល្បងប្រើប្រាស់នៅក្នុងកម្មវិធី DaVinci Resolve។ បញ្ជីនេះមិនទាន់ពេញលេញទាំងស្រុងនោះទេ ប៉ុន្តែវាប្រៀបដូចជាឯកសារការងារមួយដែលខ្ញុំនឹងត្រលប់មកមើល និងប្រើប្រាស់វាម្តងហើយម្តងទៀត។

នៅពេលខ្ញុំធ្វើការសាកល្បងជាមួយនឹងកន្សោមណាមួយ ខ្ញុំតែងតែមានទម្លាប់ដាក់ Text Node ចូលទៅក្នុង composition ហើយបញ្ចូលកន្សោមនោះទៅក្នុងប្រអប់ input របស់ styled text expression។ ការធ្វើបែបនេះអនុញ្ញាតឱ្យខ្ញុំមើលឃើញលទ្ធផលនៃកន្សោមនោះក្នុងទម្រង់ដែលអាចអានបានយ៉ាងងាយស្រួល។ បន្ទាប់មក ខ្ញុំអាចកែសម្រួលកន្សោមនោះបន្តិចបន្តួច ដើម្បីទទួលបានលទ្ធផលដែលខ្ញុំចង់បាន។

គន្លឹះមួយទៀត៖ គួរតែប្រើប្រាស់កន្សោមជាមុនសិន មុននឹងធ្វើការប្តូរឈ្មោះ node ពីព្រោះការប្តូរឈ្មោះ node វានឹងធ្វើបច្ចុប្បន្នភាពកន្សោមនោះ (update the expression) ផងដែរ។

ការដាក់សញ្ញា “--” នៅក្នុងកន្សោមសាមញ្ញ វានឹងរំលងមិនអានតួអក្សរដែលនៅខាងស្តាំសញ្ញានេះឡើយ។ ឧទាហរណ៍ដូចជា “GetPrefs("Comp.FrameFormat.Rate") -- Returns TL FPS” វាគឺជាវិធីដ៏ល្អមួយដើម្បីបន្ថែមការចងចាំ (reminder) ទៅក្នុងកូដ។

អ្វីដែលនឹងបង្ហាញជាបន្តបន្ទាប់ខាងក្រោមនេះ គឺជាបញ្ជីនៃកន្សោមរួមជាមួយនឹងការពន្យល់ (comments)។ វាគ្រាន់តែជាការរាយបញ្ជី ដោយមិនត្រូវបានរៀបចំតាមលំដាប់លំដោយជាក់លាក់ណាមួយនោះទេ។

Expression / Code Description Action
Basic for DaVinci Resolve
time Returns the current frame. (use on the "Angle" parameter to rotate an object anti-clockwise)
time-1 Returns the value of the previous frame. (time-n) (n=the previous frame number count, therefore time-10 would be 10 frames back)
-time Returns the negative value of the current frame. (use on the "Angle" parameter to rotate an object clockwise)
ceil() Rounds up to the next whole number
math.ceil() Rounds up to the next whole number
floor() Rounds down to the next whole number
math.floor() Rounds down to the next whole number
abs Convert a negative number to a positive number
time/600 Returns the current frame divided by 600 (controls speed, the higher the number the slower)
time*600 Returns the current frame multiplied by 600 (controls speed, the higher the number the faster)
sin(time) Results in a progression from -1 through to 1 with 14 decimal places.
ceil(sin(time)) Results in a progression from 0 to +1 over 2 frames as ceil round the decimal points up.
floor(sin(time)) Results in a progression -1 to 0 over 2 frames as ceil rounds the decimal points down.
comp.RenderEnd Returns the number of frames in the current composition
comp.RenderEnd/2 Returns the halfway position frame number of the composition
(1-(time/comp.RenderEnd)*2) Progression from 0 through to 1 within 50% of the comp length. Ideal for creating a responsive animation.
((comp.RenderEnd-comp.RenderStart)) Results in the number of frames in the composition
time/comp.RenderEnd Progression from 0 through to 1. Ideal for creating a responsive animation.
1-(time/comp.RenderEnd) Progression from 1 through to 0. Ideal for creating a responsive animation.
(time*360)/fps 1 Full rotation every second. (fps = the timeline framerate.) used on the "Angle" parameter
(time*360)/(fps*2) 1 Full rotation every 2 seconds. (fps = the timeline framerate.) used on the "Angle" parameter
360/copies Used on a duplicate node Angle control to divide the number of copies around a circle at equal distance.
ceil(time/fps) Results in counting up in second. (fps = the timeline framerate.)
ceil((time)/comp:GetPrefs("Comp.FrameFormat.Rate")) Results in counting up in second. (useful when fps is not known)
ceil((comp.RenderEnd-time)/fps) Results in counting down in seconds based on the composition length. (fps = the timeline framerate.)
ceil((comp.RenderEnd-time)/comp:GetPrefs("Comp.FrameFormat.Rate")) Results in counting down in seconds based on the composition length. (useful when fps is not known)
max(floor(30-(time/fps)),0) Results in counting down from 30 to 0 in whole numbers. (fps = the timeline framerate.)
ceil(time/comp.RenderEnd*100) Returns percentage up of the composition length.
ceil(time/comp.RenderEnd*100) .. "%" Returns percentage up of the composition length and concatenates the % sign at the end.
ceil((1-time/comp.RenderEnd)*100) Returns percentage down of the composition length.
ceil((1-time/comp.RenderEnd)*100) .. "%" Returns percentage down of the comp length and concatenates the % sign.
math.floor(PolylineStroke1.WriteOnEnd*100).."%" Create "Styled Text" percentage of a "Wipe On" effect.
math.floor(Circle1.Radius*100) Count up based on a circle radius.
math.floor(Rectangle1.Width*50).."%" Create "Styled Text" percentage of a "Rectangle Mask"
Random & Complex Expressions
:randomseed(floor(time/6)) ; return random() A simple 0.1.0 value changing every 6 frames
iif(time >= 0 and time <=30, (random(0,20)), 20) 0 is frame 0 and 30 is frame 30. Randomizes up to 20 and stops/holds the value on 20 after frame 30.
iif(time<10 5="" iif="" time="">= 0 and time <=30, (random(0,20)), 20)) Holds value until frame 10, then displays a random number up to 30, and stops on 20.
:if time < 10 then return 0; else return 90; end "If else" statement. Notice the ":" at the start, otherwise use iif(time<10 td="">
:freq = 0.1;amplitude = 3.5; decay = 0.1; y = amplitude*math.cos(freq*time*2*math.pi)/math.exp(decay*time); function hello() x = time*0.02;return x; end; return (y + hello()); A complex expression that includes decay.
"Progress: " .. ceil(time/comp.RenderEnd*100) .. "%" Results in Progress Percentage up the comp. ".." concatenates.
ceil((1-time/comp.RenderEnd)*100) .. "%" Results in Percentage down the comp.
"Progress: " .. ceil((1-time/comp.RenderEnd)*100) .. "%" Results in Progress Percentage down of the comp.
"Loading " .. ceil(time/24) .. "/" .. ceil(comp.RenderEnd/fps) Results in Loading Time of the comp. fps="enter the timeline fps"
Text Driven Expressions
((Text1.Output.DataWindow[4]-Text1.Output.DataWindow[2])/Text1.Output.Height) Returns the height of DataWindow of a Text node. [1]=left, [2]=top, [3]=right, [4]=bottom
((Text1.Output.DataWindow[3]-Text1.Output.DataWindow[1])/Text1.Output.Width) Returns the width of DataWindow of a Text node.
Text1.StyledText.Value OR Text1.StyledText[0] Returns the text from a text+ node.
Text1.StyledText.Value .. Text2.StyledText.Value Concatenates 2 Styled Text fields
string.len(Text1.StyledText.Value) Return the length of a String
:_, mylines = string.gsub(Text1.StyledText.Value, "\n", ""); return mylines Returns the number of lines in a Styled Text field
:_, myspaces = string.gsub(Text1.StyledText.Value, "%s", ""); return myspaces Returns the number of spaces
:_, myletters = string.gsub(Text1.StyledText.Value, "%a", ""); return myletters Returns the number of letters (not including spaces)
:_, mylower = string.gsub(Text1.StyledText.Value, "%l", ""); return mylower Returns number of lower case (numbers included)
:_, myupper = string.gsub(Text1.StyledText.Value, "%u", ""); return myupper Returns the number of UPPER case characters
:_, alphanumeric = string.gsub(Text1.StyledText.Value, "%w", ""); return alphanumeric Returns the number of alphanumeric
:_, myvow = string.gsub(Text1.StyledText.Value, "[AEIOUaeiou]", ""); return myvow Returns the number of vowels
:_, novow = string.gsub(Text1.StyledText.Value, "[^AEIOUaeiou]", ""); return novow Returns anything except vowels (includes spaces, controls & numbers)
:_, mydigits = string.gsub(Text1.StyledText.Value, "%d", ""); return mydigits Returns the number of digits
:_, punctuation = string.gsub(Text1.StyledText.Value, "%p", ""); return punctuation Returns the number of punctuations
:_, controlchar = string.gsub(Text1.StyledText.Value, "%c", ""); return controlchar Returns the number of control characters
:_, myhex = string.gsub(Text1.StyledText.Value, "%x", ""); return myhex Returns the number of hexdeciaml digits
:_, myletters = string.gsub(Text1.StyledText.Value, "%A", ""); return myletters Returns how many non letters. Adding the ^ (caret) before the % will return the number of everything except.
min(time/(comp.RenderEnd/2),1)-(Text1.Delay) Used in the scrambled text randomness to end the scramble halfway through the comp. Delay is a slider set from 0 to .25.
1-(time/comp.RenderEnd) Used in the scrambled text randomness from scrambled to the word.
Write On Expression
time/(comp.RenderEnd/fps) Results in one letter per frame "write on".
time/(comp.RenderEnd/fps)*2 Results in two letters per frame "write on".
time/(comp.RenderEnd/comp:GetPrefs("Comp.FrameFormat.Rate"))/2 Results in the word "write on" within half the fps when the framerate isn't known.
time/(comp.RenderEnd/comp:GetPrefs("Comp.FrameFormat.Rate"))/(Text1.WriteOn) Adding a slider Control "WriteOn" allows user to control write on speed.
Mask Expressions
floor(-1*((Rectangle1.Height))/2) OR floor(-Rectangle1.Height)/2 Returns the bottom position of a mask.
floor((Rectangle1.Height)/2) Returns the top position of a mask.
Point(Rectangle1.Center.Y-(Rectangle1.Width/2)+(Rectangle1.Width/2)) Place the edge of item on the inside left of mask
Point(Rectangle1.Center.Y-(Rectangle1.Width/2)-(Rectangle1.Width/2)) Place the edge of item on the outside left of mask
Point(Rectangle1.Center.X, (Rectangle1.Center.Y+(Rectangle1.Height/2))) Returns the top position of a rectangle mask
Point(Rectangle1.Center.X, (Rectangle1.Center.Y-(Rectangle1.Height/2))) Returns the bottom position of a rectangle mask
Point(Rectangle1.Center.X+(Rectangle1.Width/2)) Returns the Right position of a rectangle mask
Point(Rectangle1.Center.X-(Rectangle1.Width/2)) Returns the left position of a rectangle mask
math.floor(((Transform1.XSize*100)-100)+100).."%" % reading to Empty. % reducing as width of RectangleMask gets smaller.
math.floor((100-Transform1.XSize*100)).."%" % reading to Full. % increasing as width of RectangleMask gets larger.
Displays the date & OS functions
Text1.StyledText = os.date('%x') Returns the date. Change the %x to:
%a (Wed), %A (Wednesday)
%b (Sep), %B (September)
%c (date/time), %d (day), %m (month)
%H (24hr), %I (12hr), %M (min), %S (sec), %p (am/pm)
%Y (1998), %y (98), %w (weekday 0-6)
os.execute ("start ../galleries/gallery.html" ) Open a local web page (Windows)
os.execute ("open ../galleries/gallery.html" ) Open a local web page (Mac)
os.execute('open "" "https://...blog.blogspot.com/"') Opens a Webpage (Mac) - Used inside an edit control button
os.execute('start "" "https://...blog.blogspot.com/"') Opens a webpage (Windows) - Used inside an edit control button
UserControls = ordered() { ScriptButton = { LINKS_Name = "ScriptButton", LINKID_DataType = "Number", INPID_InputControl = "ButtonControl", INP_Integer = false, BTNCS_Execute = [[ os.execute('open "" "https://www.resolvebrowser.co.uk"') os.execute('start "" "https://www.resolvebrowser.co.uk"') ]], ICS_ControlPage = "Controls" } } LUA for adding a button to a node in a text editor. Placed below `ViewInfo = OperatorInfo...`
Reference a value / Get Values
Transform1:Angle The result is the angle of the transform node. (nodeName:property)
Rectangle1:GetValue("Width", 10) Returns the width of the node "Rectangle1" at frame 10
Rectangle1.Width Returns the value of the width from "Rectangle1" node at every frame
Merge1:GetValue("Center", time-1).X Get the X-coordinate of a point from the previous frame
self:GetValue(....) Get the value of a control on the same tool at a different time
self:GetSourceTool("[connected input]"):GetValue("[source parameter]",[source time]) Get A Previous Node Value (e.g. self:GetSourceTool("EffectMask"):GetValue(("Width*2",time*2)))
iif(time>=25 and time<=200, ceil(((time-25)/(200-25)*100)) .. "%",iif(time<25 span=""> Clock starts ticking at frame 25 and increases to 100% at frame 200.
Composition & Timeline Properties
comp:GetPrefs( ) Returns information about the current composition
comp:GetPrefs("Comp.FrameFormat.Rate") Determine Users Timeline Frame Rate
comp:GetPrefs("Comp.FrameFormat.Width") Returns the width of the Timeline resolution (e.g. 1920)
comp:GetPrefs("Comp.FrameFormat.Height") Returns the height of the Timeline resolution (e.g. 1080)
self.Input.OriginalWidth Returns width of input resolution (e.g. 4K video = 3840)
self.Input.OriginalHeight Returns height of input resolution (e.g. 4K video = 2160)
min(Background1.GlobalOut,F1.FPS) KeyframeStretcher - responsive based on global in/out.
Switches, If-then-else & TimeStretcher
iif((comp.RenderEnd-time)<(comp.RenderEnd/2),0,1) Switches from background to foreground inputs at halfway point
iif(Animation>=1,1,0) Switch on a combo / Switch 01 Expression
iif(Switch02.Animation>1,1,0) Switch 02 Expression
timeHold_Frame+Hold_Time and time-Hold_Time or Hold_Frame TimeStrecher Animation Pause Node
iif(Merge1.Blend > 0.5, 1, 0) Toggle value based on a condition
(Merge1.Blend > 0.5) and 1 or 0 Alternative logic to toggle value based on a condition
Operators & Formulas
x + y / x - y / x * y / x / y / x ^ y / x % y Basic Mathematical Operators: plus, minus, multiply, divide, power, modulo
x < y / x > y / x <= y / x >= y Returns 1.0 if true, otherwise 0.0
x = y / x == y Returns 1.0 if x is exactly equal to y, otherwise 0.0
x <> y / x != y Returns 1.0 if x is NOT equal to y, otherwise 0.0
x & y / x && y 1.0 if both x and y are not 0.0, otherwise 0.0 (AND)
x | y / x || y 1.0 if either x or y are not 0.0, otherwise 0.0 (OR)
log(x) / ln(x) Base-10 log of x / Natural (base-e) log of x
sin(x) / cos(x) / tan(x) Trigonometric functions (x is in degrees)
int(x) / frac(x) / sqrt(x) Integer, fractional value, and Square Root of x
rand(x, y) / rands(x, y, s) Random value between x and y (s = seed)
min(x, y) / max(x, y) Minimum / Maximum of x and y
dist(x1, y1, x2, y2) / dist3d(x1,y1,z1,x2,y2,z2) Distance between points or 3D points
noise(x) / noise2(x,y) / noise3(x,y,z) Perlin noise value based on x, y, z
if(c, x, y) Returns x if c <> 0, otherwise y
Easing Expressions
1 - cos((time/comp.RenderEnd * pi) / 2) easInSine
sin(((time/comp.RenderEnd) * pi) / 2) easeOutSine
-(cos(pi * (time/comp.RenderEnd)) - 1) / 2 easeInOutSine
(time/comp.RenderEnd) * (time/comp.RenderEnd) easeInQuad
1 - (1 - (time/comp.RenderEnd)) * (1 - (time/comp.RenderEnd)) easeOutQuad
iif((time/comp.RenderEnd) < 0.5, 2 * (time/comp.RenderEnd) * (time/comp.RenderEnd), 1 - pow(-2 * (time/comp.RenderEnd) + 2, 2) / 2) easeInOutQuad
(time/comp.RenderEnd)^3 easeInCubic
1-(1-time/comp.RenderEnd)^3 easeOutCubic
iif((time/comp.RenderEnd < 0.5), (((time/comp.RenderEnd)^3)*4), 1-(((1-time/comp.RenderEnd)^3)*4)) easeInOutCubic
(time/comp.RenderEnd) ^ 4 easeInQuart
1 - pow(1 - (time/comp.RenderEnd), 4) easeOutQuart
iif((time/comp.RenderEnd) < 0.5, 8 * (time/comp.RenderEnd) * (time/comp.RenderEnd) * (time/comp.RenderEnd) * (time/comp.RenderEnd), 1 - pow(-2 * (time/comp.RenderEnd) + 2, 4) / 2) easeInOutQuart
(time/comp.RenderEnd)^5 easeInQuint
1 - pow(1 - (time/comp.RenderEnd), 5) easeOutQuint
iif((time/comp.RenderEnd) < 0.5, 16 * (time/comp.RenderEnd) *(time/comp.RenderEnd) * (time/comp.RenderEnd) * (time/comp.RenderEnd) * (time/comp.RenderEnd), 1 - pow(-2 * (time/comp.RenderEnd) + 2, 5) / 2) easeInOutQuint
pow(2, 10 * (time/comp.RenderEnd) - 10) easeInExpo
1 - pow(2, -10 * (time/comp.RenderEnd)) easeOutExpo
iif((time/comp.RenderEnd) < 0.5, pow(2, 20 * (time/comp.RenderEnd) - 10) / 2, (2 - pow(2, -20 * (time/comp.RenderEnd) + 10)) / 2) easeInOutExpo
1 - sqrt((1 - (time/comp.RenderEnd) ^ 2)) easeInCirc
sqrt(1 - pow((time/comp.RenderEnd) - 1, 2)) easeOutCirc
iif((time/comp.RenderEnd < 0.5), (1 - sqrt((1 - (2 * (time/comp.RenderEnd)) ^ 2))) / 2, (sqrt(1 - (-2 * (time/comp.RenderEnd) + 2) ^ 2) + 1) / 2) easeInOutCirc
(1.70158 + 1) * (time/comp.RenderEnd) * (time/comp.RenderEnd) * (time/comp.RenderEnd) - 1.70158 * (time/comp.RenderEnd) * (time/comp.RenderEnd) easeInBack
1 + (1.70158 + 1) * pow((time/comp.RenderEnd) - 1, 3) + 1.70158 * pow((time/comp.RenderEnd) - 1, 2) easeOutBack
iif((time/comp.RenderEnd) < 0.5, (pow(2 * (time/comp.RenderEnd), 2) * ((2.594909 + 1) * 2 * (time/comp.RenderEnd) - 2.594909)) / 2, (pow(2 * (time/comp.RenderEnd) - 2, 2) * ((2.594909 + 1) * ((time/comp.RenderEnd) * 2 - 2) + 2.594909) + 2) / 2) easeInOutBack
Fake Timer
Text("9:".. max(30-floor(time/comp:GetPrefs("Comp.FrameFormat.Rate")),0)) Make a fake timer which starts 9: then counts down 30 seconds. (Change "9" to any number or word)
max(floor((Text1.N1+1)-(time/comp:GetPrefs("Comp.FrameFormat.Rate"))),0) Fake Timer with extra controls (sliders or CustomTool for user control)
________________
ប្រភពពី another-davinci-resolve-blog.blogspot.com

No comments

Post a Comment

៙ គោលការណ៍ក្នុងការផ្តល់យោបល់ ៖
1. យោបល់ត្រូវតែសរសេរជាភាសាខ្មែរ ពាក្យបច្ចេកទេសអាច​សរសេរជាភាសាអង់គ្លេស។
2. យោបល់មិនត្រូវលើសពី 1000 តួអក្សរឡើយ។ ការបំបែកយោបល់មិនត្រូវបានអនុញ្ញាតទេ។
3. យោបល់ដែលចាត់ទុកថាជា Spam ឬមានគោលបំណងផ្សព្វផ្សាយពាណិជ្ជកម្មតែមួយមុខ នឹងត្រូវលុប។
4. ការពិភាក្សាអំពីនយោបាយមិនត្រូវបានអនុញ្ញាតនៅលើគេហទំព័រនេះទេ។
5. ការចែករំលែកតំណភ្ជាប់ដែលពាក់ព័ន្ធត្រូវបានអនុញ្ញាត។ តំណភ្ជាប់និងតម្រងពាក្យ​ខ្លះ​ត្រូវ​បាន​ហាមឃាត់។
6. យោបល់ដែលរអ៊ូរទាំអំពីប្រធានបទនៃការបង្ហោះ ឬប្រភពរបស់វានឹងត្រូវលុប។
7. ការប្រើភាសាប្រមាថក្នុងយោបល់ ឬឈ្មោះអ្នកប្រើប្រាស់នឹងបណ្តាលឱ្យមានការហាមឃាត់។
8. ការវាយប្រហារ/ការបៀតបៀនដោយផ្ទាល់ នឹងបណ្តាលឱ្យមានការហាមឃាត់ភ្លាមៗ។
9. អ្នកសម្របសម្រួលអាចកែប្រែ/លុបយោបល់ដោយមិនចាំបាច់ជូនដំណឹង។