# Sprite DX - Stage 3 - Adding Custom ComfyUI Nodes

I’m codifying the exercise we did in [previous post](https://blog.sprited.app/sprite-dx-stage-3-splitting-shots) into a ComfyUI custom node.

## Node 1 - Video Downloader

First node we will create is a video downloader. Right now, when Fal.ai generates a video it provides a URL to download that video file. We now need to download the video into local drive so that we can run it through *PySceneDetect* node we will create later down the line.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1754084927509/79085a0d-f513-4fda-98f8-03c476098389.png align="center")

Source code: [https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited\_nodes/download\_video.py](https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited_nodes/download_video.py)

It basically downloads the image url given by the Fal.ai and just saves the file into a tmp folder, so that we can pick it up later.

All good so far.

---

## Node 2 - Shot Splitter

Now, we create a node that uses *PySceneDetector* approach discussed in previous [post](https://blog.sprited.app/sprite-dx-stage-3-splitting-shots#heading-pyscenedetect) to split the video into multiple videos each containing distinct shots.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1754100400124/4ddc5080-fa88-489d-9c2a-af0007bd0a85.png align="center")

Source code: [https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited\_nodes/split\_shots.py](https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited_nodes/split_shots.py)

So far so good. Let’s move on to loop detection.

---

## Node 3 - Loop Detection

Finally, we use the post-processing approach discussed [previously](https://blog.sprited.app/sprite-dx-stage-3-splitting-shots#heading-post-processing-detect-loop), to extract meaningful loops from the video and save them

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1754100565409/25aa07af-9928-4b89-9644-24bc4a76308d.png align="center")

Source code: [https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited\_nodes/extract\_loop.py](https://github.com/sprited-ai/sprited-comfyui-nodes/blob/main/src/sprited_nodes/extract_loop.py)

---

## Results

Results can be seen in the previous [post](https://blog.sprited.app/sprite-dx-stage-3-splitting-shots#heading-final-outcome).

---

## Conclusion

ComfyUI Custom Nodes sure has some learning curve but it was relatively straightforward to add custom nodes. We now have Stage 3 of SpriteDX pipeline in ComfyUI.

Next Step?

* It is still rough round the edges. I will need to test it further to make sure stage 3 works with good success rate.
    
* Find replacement for Fal.ai. It is little too expensive. It would be good to be able to use many providers and switch between them on-demand.
    
* Next, we would want to convert the mp4 files into frames and run it through [background removal algorithm](https://blog.sprited.app/sprite-animation-generation-background-removal-2).
    

—Sprited Dev
