रेफ़रेंस
स्क्रिप्टिंग
इस पेज पर
जब कोई काम प्रोग्राम के रूप में आसान हो, तब स्क्रिप्ट इस्तेमाल करें: हर बीट पर कट करना, हर हिट पर इफ़ेक्ट लगाना, कट करने से पहले नापना। nolan Python क्लाइंट और nolan-cli बटनों और एजेंट वाले उन्हीं ऑप्स तक पहुँचते हैं, इसलिए हर बदलाव की जाँच होती है, और स्क्रिप्ट से किया बदलाव इतिहास में एक स्टेप होता है।
सेटअप
क्लाइंट को Python 3.10 या नए के सिवा कुछ नहीं चाहिए। OpenTimelineIO ज़रूरी नहीं, यह to_otio() के लिए है। ऐप क्लाइंट को अपने रिसोर्स में python-client नाम के फ़ोल्डर में रखता है। Mac पर, जब ऐप Applications में हो:
pip install /Applications/nolanlabs.app/Contents/Resources/python-client
OpenTimelineIO के लिए पाथ के आख़िर में [otio] जोड़ें, या इसकी जगह फ़ोल्डर को PYTHONPATH पर रखें।
क्लाइंट चलते हुए ऐप को अपने आप ढूँढ लेता है। अगर आप NOLAN_URL सेट करते हैं, तो वही चलता है। हर रिक्वेस्ट सर्विस का सीक्रेट साथ ले जाती है: चलते ऐप के बगल में क्लाइंट और CLI उसे ख़ुद पढ़ लेते हैं, इसलिए कुछ सेट नहीं करना। किसी और जगह की सर्विस के लिए NOLAN_TOKEN उसे बताता है।
पहली स्क्रिप्ट
import nolan
s = nolan.connect() # NOLAN_URL, or http://127.0.0.1:8790
tl = s.timeline() # NOLAN_TIMELINE, or the first timeline
music = s.sources("Music")[0]["id"]
beats = s.sound(music, fps=tl.fps)["beats"]
with tl.transaction("Cut to the beat"): # one step in the history; dropped if the block raises
for clip, beat in zip(tl.track("V1").items, beats[4::4]):
if clip.end > beat:
clip.trim("tail", beat - clip.end, ripple=True)
tl.track("V1").items[0].effect("grain", 0.3)
print(tl.summary()["mean_shot_s"])
ट्रांज़ैक्शन के बाहर हर बैच अपने अलग स्टेप के रूप में टाइमलाइन पर आता है। with tl.transaction(label) के अंदर बैच एक ट्रांज़ैक्शन में जाते हैं जिसे पेज एजेंट के प्रपोज़ल की तरह दिखाता है, और ब्लॉक के ख़त्म होने पर वह एक स्टेप के रूप में रखा जाता है। जिस बैच को इंजन मना करे, वह nolan.NolanError उठाता है, op_index कमांड का नाम बताता है, और कुछ नहीं बदलता।
कोई भी ऑप चलाएँ
हर ऑप डोमेन के हिसाब से एक फ़ंक्शन है, उसके फ़ील्ड आर्ग्युमेंट के रूप में और एक डॉकस्ट्रिंग जो हर एक की यूनिट और रेंज बताती है। जो फ़ील्ड मौजूद नहीं, उसे मना कर दिया जाता है और मौजूद फ़ील्ड बताए जाते हैं। यहाँ session वह है जो nolan.connect() लौटाता है।
nolan.ops.clip.trim(clip="c4", edge="tail", delta=-6, tl=tl)
nolan.ops.text.add(at=24, len=48, text="NEXT LEVEL", look="impact", y=0.2, in_="slam", in_len=6, tl=tl)
beats = nolan.analyse.sound("Rocket")["beats"] # nolan.analyse and nolan.track are nolan.ops.analyse and .track
tl.edit([{"op": "clip.dissolve", "clip": "c5", "frames": 12},
{"op": "grade.primary", "clip": "c5", "temp": 0.15}], name="Warmer")
tl.do("timeline.marker_add", at=96, name="Drop")
session.op("deliver.render", preset="prores", path="/out/master.mov")
जो फ़ील्ड Python के शब्द हैं, वे आर्ग्युमेंट के रूप में आख़िर में _ लेते हैं (in_, from_)। tl.edit और tl.do में वे अपने नाम रखते हैं। nolan.ops.CATALOGUE में हर ऑप अपने फ़ील्ड के साथ है, और nolan.ops.catalogue() एडिटर से पूछता है, प्लग-इन समेत।
आप जो करना चाहते हैं उसके हिसाब से
# Bring things in, and cut them
s.import_media(["/footage/a.mov", "/footage/b.mov"])
tl.insert("a", 0, length=48, overwrite=True)
# Grade with wheels and curves, and a LUT
clip.grade(lift=[0, 0, .02], gain=[.05, 0, -.03], curves={"m": [[0, 0], [.5, .55], [1, 1]]})
clip.grade(lut="film.cube", lut_mix=.6) # in the project's LUTs folder, or a full path
# Read the frame from the originals, and check the numbers
print(tl.scopes(at=48)["luma"])
# Mask, track and move the mask with what it follows
clip.set(masks=[{"shape": "ellipse", "x": .5, "y": .4, "w": .3, "h": .5, "feather": .05, "invert": True}])
path = s.track(clip.src, clip.source_in, clip.source_in + clip.length, x=.5, y=.4, w=.3, h=.5, mode="move")
clip.track_apply(path, target="mask:0")
# Words on an arc, letter by letter
tl.title("STUNT SHOW", 0, 72, path=[[.2, .6], [.5, .4], [.8, .6]], by="char",
per=[{"prop": "opacity", "stagger": 2, "keys": [{"f": 0, "v": 0}, {"f": 8, "v": 1}]}])
# Sound
clip.set(afx=[{"kind": "highpass", "freq": 80}, {"kind": "reverb", "size": .4, "mix": .15}], pan=-.2)
# Cameras
angles = s.sync(["cam_a", "cam_b"])
tl.multicam(angles, at=0, length=240)
# Deliver anything
tl.render("/out/master.mov", preset="prores", profile="hq", audio="pcm24", loudness=-16)
tl.render("/out/frames", sequence="exr", alpha=True)
tl.render("/out/hdr.mov", codec="prores", profile="hq", hdr="pq") # cache=True does nothing for HDR or EXR
tl.export("fcpxml", "/out/cut.fcpxml")
हर मेथड एक बैच भेजता है और टाइमलाइन वापस पढ़ता है, इसलिए ऑब्जेक्ट टाइमलाइन को वैसे दिखाते हैं जैसी वह बदलाव के बाद है। दो हिस्सों में कटी क्लिप बाएँ हिस्से पर अपनी id रखती है।
कोड से मीडिया बनाएँ
प्रोग्राम वह बना सकता है जो वह टाइमलाइन पर रखता है। इनमें से हर एक फ़ाइल को प्रोजेक्ट के Media/Generated में लिखता है, उसे इम्पोर्ट करता है और जो वहाँ है उसके ऊपर रखता है, कुछ भी खिसकाए बिना, इतिहास में एक स्टेप के रूप में। अनडू क्लिप हटा देता है, और सोर्स पूल में रहता है।
import numpy as np
from PIL import Image, ImageDraw
# A picture: an array or a Pillow image, for 5 seconds at the end of the track unless you say
picture = Image.new("RGBA", (tl.width, tl.height), (0, 0, 0, 0))
ImageDraw.Draw(picture).ellipse((200, 100, 600, 500), fill=(255, 80, 0, 255))
tl.add_image(picture, at=0, length=48, track="V2", name="Disc")
# Moving pictures: a generator is sent as it makes them, so length costs no memory
def noise():
rng = np.random.default_rng(7)
for i in range(96):
yield rng.random((tl.height, tl.width, 3)) * (i / 96)
tl.add_frames(noise(), fps=tl.fps, at=48, name="Noise")
# Sound: float from -1 to 1, or int16; one channel or (samples, channels)
t = np.arange(96000) / 48000
tl.add_audio(np.sin(2 * np.pi * 110 * t) * 0.3, rate=48000, at=0, track="A2", name="Hum")
| कॉल | क्या लेता है | क्या बनता है |
|---|---|---|
tl.add_image(image, at, length, track, name) |
(H, W), (H, W, 1), (H, W, 3) या (H, W, 4) का ऐरे, uint8, uint16 या 0 से 1 तक float में, या Pillow इमेज | एक PNG, uint16 या float से 16-बिट |
tl.add_frames(frames, fps, at, length, track, name) |
इन्हीं का जनरेटर या लिस्ट, या एक ऐरे (T, H, W[, C]) | ProRes 422 HQ, या अल्फ़ा के साथ 4444 |
tl.add_audio(samples, rate, at, length, track, name) |
एक ऐरे (N,) या (N, channels), float या int16, या चंक का जनरेटर | एक 24-बिट WAV |
ऐरे और इमेज आपके प्रोग्राम के अपने हैं, इसलिए इनके लिए NumPy और Pillow आपको ख़ुद इंस्टॉल करने हैं।
शेल से काम करें
nolan-cli [--url URL] [--project NAME|FOLDER|ID] [--timeline ID] COMMAND
projects | open PATH [--force] | close [NAME] [--stop] the projects open at once
runs [--state S] | ask PROMPT [--thread T] [--wait] the agent of --project (or the one the app shows)
answer RUN OPTION [--note N] | cancel RUN
host status | host restart|stop [--when idle|now] | host cancel
run [--label L] [--dry-run] script.py [-- args] a script, in one transaction
summary | ops [WORDS] | lookup WORDS read; ops lists every op with its fields
op NAME [FIELD=JSON ...] [--dry-run] any op: op clip.trim clip=c4 edge=tail delta=-6
inspect WHAT [FIELD=JSON ...] the agent's inspect tool: inspect clips track=V1
look WHAT [FIELD=JSON ...] [--out DIR] the agent's look tool; pictures saved to DIR, their paths printed
wait ID [--timeout S] | busy | background wait for a script in the background (r1) or a render (j1); what still runs
apply '[{"op": "split", "at": 48}]' [--dry-run] any engine commands
clip ID [FIELD=JSON ...] read or change a clip
render [--out F] [--preset P] [--from A] [--to B] [FIELD=JSON ...] waits for it
export otio|fcpxml|edl|aaf [OUT] [--track V2] import FILE
scopes [--at F] | cache [--from A --to B --wait] sheet OUT.jpg [--count N]
fonts | font FILE | relink [--folder D | --src ID --path F]
add image|frames|audio [--name N] [--at F] [--length L] [--track V2]
[--width W --height H --pix rgb24 --fps F | --rate R --channels C --format f32le] < RAW
run आपकी स्क्रिप्ट को nolan, session और tl तैयार रखकर एक ट्रांज़ैक्शन के अंदर चलाता है: ठीक से ख़त्म होने पर एक स्टेप के रूप में रखा जाता है, एरर उठने पर छोड़ दिया जाता है। --dry-run बताता है कि उसने क्या किया और उसे छोड़ देता है। इस तरह चलाई गई स्क्रिप्ट आपकी हैं और सेफ़ मोड के बिना चलती हैं। python -m nolan वही कमांड है।
किसी भी भाषा से, nolan-cli add पाइप से रॉ डेटा पढ़ता है:
my_renderer | nolan-cli add frames --width 1920 --height 1080 --pix rgb24 --fps 24 --track V2 --name Sim
my_synth | nolan-cli add audio --rate 48000 --channels 2 --format f32le --at 96
किसी भी खुले प्रोजेक्ट तक पहुँचें
nolan-cli --project NAME ऐप की विंडो बदले बिना उस प्रोजेक्ट में काम करता है। Python में nolan.project(name) भी यही करता है:
import nolan
teaser = nolan.project("Launch Teaser")
teaser.timeline().marker(48, "From the script") # edits that project, whatever the app's window shows
run = teaser.agent.ask("Tighten the second half") # a Run: id, thread, status (running, paused, done, failed, cancelled), and what it waits on you for
run.wait() # waits through a restart: a paused run carries on by itself
for r in nolan.runs(state="waiting"): # every open project's runs that wait for an answer
print(r.project, r.title)
teaser.close(stop=False) # refused while its work goes, unless stop=True
nolan.host.status(); nolan.host.restart(when="idle")
मोड बदलें और अपडेट करें
s.mode ऐप का मोड है, "lite" या "pro", और s.set_mode("pro") उसे बदलता है। nolan-cli mode उसे दिखाता है, और nolan-cli mode lite बदलता है।
nolan-cli update # or: update check, update install
हर ऑब्जेक्ट में क्या है
| ऑब्जेक्ट | इसमें क्या है |
|---|---|
Session |
project, timelines, timeline(id), new_timeline, new_project, open, import_media, add_media, sources(q), sound, sfx, sync(srcs, by), motion, track, shake, subject, key_colour, relink, fonts(), import_font(path), import_timeline(path), set_proxy(size), set_agent(access, ask_me), style(), set_style(user, project), plugins(), save_generator(name, code, params), op(name, **fields), run_script(code) |
Timeline |
पढ़ना: fps, width, height, length, markers, tracks, track(id), clips, clip(id), at(frame, track), summary(), checks(), frame(at, path), still(at, path), contact_sheet(path), scopes(at, pictures, hdr), cache(frm, to, wait), mix(), watch()। बदलना: edit(ops, name), do(name, **fields), apply(commands), op(command, **fields), dry_run(commands), transaction(label), undo(), insert, lay, add_image, add_frames, add_audio, split, title, marker, add_track, compound(frm, to), decompose(clip), multicam(angles, at)। बाहर: render(path, preset, frm, to, **deliver), export(kind, path, track), otio_json(), to_otio() |
Track |
id, kind, name, items, set(**fields) |
Clip |
id, track, src, at, end, length, source_in, title, anim, fx, speed; trim, roll, slip, slide, move, split, delete, set, keyframe, effect, motion, transition, grade, track_matte, track_apply, stabilize |
एजेंट की स्क्रिप्ट
एजेंट के पास भी यह क्लाइंट है। उसकी चलाई स्क्रिप्ट एक ड्राफ़्ट पर काम करती है, जो उसके प्रपोज़ल की कॉपी है। स्क्रिप्ट ठीक से ख़त्म होने पर सब कुछ एक बैच के रूप में प्रपोज़ल में जाता है। फ़ेल होने पर कुछ नहीं रखा जाता, और उसका बनाया मीडिया भी हट जाता है।
एजेंट की स्क्रिप्ट सेफ़ मोड में चलती हैं: सीमित इम्पोर्ट, लिखना सिर्फ़ उनके अपने अस्थायी फ़ोल्डर के अंदर, कोई नया प्रोसेस नहीं, और समय, CPU और मेमोरी की सीमाएँ। Windows पर डिस्क का रीड-ओनली व्यू नहीं है और मेमोरी की सीमा नहीं है। सेफ़ मोड ग़लतियों से बचाव है, सुरक्षा की दीवार नहीं। देखें ज्ञात सीमाएँ। आपकी अपनी स्क्रिप्ट से आए प्रपोज़ल में रखें और हटाएँ होते हैं। देखें प्रपोज़ल।