$ cat node-template.py
V
Video Shot Detect (Neural)
// Detects shot boundaries in video using neural network analysis. Fast and accurate shot detection for professional video editing workflows.
Process
#video#scene-detection#shot-detection#transnetv2#neural-network
template.py
1import os2import sys3import json4import traceback56from gais import Gais78INPUT_DIR = "/data/input"91011def main():12 try:13 input_json = sys.stdin.read()14 execution_input = json.loads(input_json)15 inputs = execution_input.get("inputs", {})1617 video = inputs.get("video", "")18 threshold = inputs.get("threshold", 0.5)1920 if not video:21 raise ValueError("Video input is required")2223 video_path = os.path.join(INPUT_DIR, video)24 if not os.path.exists(video_path):25 raise FileNotFoundError(f"Input video not found: {video_path}")2627 print(28 f"Detecting shot boundaries: threshold={threshold}",29 file=sys.stderr,30 )3132 result = Gais.detect.shots(33 video=video_path,34 threshold=float(threshold),35 )3637 result_data = json.loads(result.content)3839 scenes = result_data.get("scenes", [])40 total_scenes = result_data.get("total_scenes", 0)41 video_duration = result_data.get("video_duration", 0.0)42 fps = result_data.get("fps", 0.0)43 total_frames = result_data.get("total_frames", 0)44 processing_time = result_data.get("processing_time_ms", 0)4546 print(47 f"Detection complete: {total_scenes} shot boundaries found, "48 f"duration={video_duration}s, fps={fps}, frames={total_frames}, "49 f"processing_time={processing_time}ms",50 file=sys.stderr,51 )5253 # Flat output — keys match OUTPUT_SCHEMA54 # scenes is serialized as JSON Text for downstream Text consumers55 output = {56 "scenes": json.dumps(scenes),57 "total_scenes": total_scenes,58 "video_duration": video_duration,59 "fps": fps,60 "total_frames": total_frames,61 }62 print(json.dumps(output, indent=2))6364 except Exception as e:65 error_output = {66 "error": str(e),67 "errorType": type(e).__name__,68 "traceback": traceback.format_exc(),69 }70 print(json.dumps(error_output), file=sys.stderr)71 sys.exit(1)727374if __name__ == "__main__":75 main()$ git log --oneline
v1.4.0
HEAD
2026-05-07v1.1.02026-04-09