Run Python code on the project's files
run_codeRun Python on the project's files and get files back as project assets. Use it for work the film's own tools do not do: data to a chart (a CSV to a rendered PNG and the JSON an animated chart component reads), a map from GeoJSON, measuring audio (onsets, beats, loudness, pitch) or images (colours, edges, faces), procedural assets (a GLB model for a 3D world, an SVG, a PNG texture, a pattern), file conversions (ffmpeg, a font, a table) and batch work over many files. Do not use it for motion, camera or timing: a follow, a frame, keys and cuts belong in the film. The sandbox has Python 3 with numpy, pandas, scipy, matplotlib (Inter is its font), pillow, opencv, librosa, soundfile, trimesh, pygltflib, shapely, svgpathtools, cairosvg, geopandas, pyproj, requests and the ffmpeg command, and internet access for pip install and public data. Put assets in with assetIds and the film, transcripts, beats and analysis with their fields; /input/manifest.json lists them. Every file the code writes under /output (or the ones outputs names) becomes a project asset: an image, a video, a sound, a 3D model (.glb), a data file (.json, .csv, .geojson, .svg, up to 2 MB) or a font. When the code writes no file there, a figure it shows becomes an image asset. The answer gives each new Asset ID with its line, the printed output and the last expression's value. A Python error comes back with its traceback: fix the code and run it again. Files in /work, imports and variables stay for the next run_code call in this project for 30 minutes. Uses about 0.84 credits a minute, billed by the second while the code runs and its files go in and out; a call that fails on Vidova's side costs nothing. A call that runs past about 45 seconds answers with a Job ID: wait_for_jobs gives its result. Read guide/run-code for worked examples.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python 3 to run. It runs in a Jupyter kernel with /work as the working folder: print what you want to read, and the last expression comes back too. Write every file that should become a project asset under /output. | |
| film | Yes | true puts the film's files (main.film and its modules) in /input/film. null leaves them out. | |
| beats | Yes | Assets whose measured beats go in /input/beats/<assetId>.json: the tempo, beats and downbeats in source seconds. null puts none. | |
| outputs | Yes | Paths under /output to import, such as ["/output/chart.png"]. null imports every file the code wrote under /output in this call. | |
| analysis | Yes | Assets whose completed analysis rows (scenes, sound events, tracks and the rest) go in /input/analysis/<assetId>/<plugin>.json. null puts none. | |
| assetIds | Yes | Project assets to put in /input, each at /input/<file name>: a video as its playable MP4, any other file as it was uploaded or made. /input/manifest.json lists every file with its asset id, kind, duration, size and path. null puts none. | |
| projectId | Yes | The project this call runs on without changing the open project. null (or leaving it out) uses the open project. wait_for_jobs takes the projectId of the calls that started the jobs. | |
| transcripts | Yes | Assets whose transcript goes in /input/transcripts/<assetId>.json: segments and words with their source seconds. null puts none. | |
| timeoutSeconds | Yes | The most the code may run, 10 to 600 seconds. null is 120. |