Skip to content

GizmoQuest/comfycam

 
 

Repository files navigation

ComfyCam

ComfyCam is a tool that captures AI-processed video frames from ComfyStream and outputs them to a virtual camera device, allowing you to use the processed video stream in any application that supports video input (like OBS, Zoom, etc.).

Prerequisites

System Requirements

  • Ubuntu 24.04 (tested and verified)
  • NVIDIA GPU with CUDA support
  • Docker

Virtual Camera Setup and Usage

Important

The virtual camera setup requires kernel module installation and loading. This is a system-level operation that should be done with caution. The configuration has been tested on Ubuntu 24.04 with Docker and may require adjustments for other distributions.

  1. Install the required kernel modules:
sudo apt update
sudo apt install dkms v4l2loopback-dkms
  1. Reboot your system to ensure the kernel modules are properly loaded:
sudo reboot
  1. After reboot, load the v4l2loopback module with the following parameters:
sudo modprobe v4l2loopback video_nr=2 card_label="ComfyCam" exclusive_caps=1 max_buffers=8
  1. Clone the ComfyCam repository:
git clone https://github.com/GizmoQuest/comfycam.git
  1. Navigate to the project directory:
cd comfycam
  1. Build the Docker images. This will create two images:
    • comfycam-base:latest: The base image with all dependencies
    • comfycam:latest: The final image with ComfyCam and ComfyStream
docker build -f docker/Dockerfile.base -t comfycam-base:latest . && docker build -f docker/Dockerfile -t comfycam:latest --build-arg BASE_IMAGE=comfycam-base:latest .
  1. Run the container:
docker run -it --gpus all \
  -p 8188:8188 \
  -p 8889:8889 \
  -p 5678:5678 \
  --device=/dev/video2 \
  --name comfycam \
  -v ~/models/ComfyUI--models:/workspace/ComfyUI/models \
  -v ~/models/ComfyUI--output:/workspace/ComfyUI/output \
  comfycam:latest \
  --download-models --build-engines --server
  1. Start the Comfystream server and UI (Use Runpod settings)

  2. Launch your Comfy Workflow (JSON API file)

  3. Deploy ComfyCam in a new terminal

docker exec -ti comfycam \
    conda run -n comfystream \
    --no-capture-output \
    python /workspace/comfystream/comfycam_bridge.py
  1. Use ComfyCam with your application (OBS, Zoom, etc)

Troubleshooting

Common Issues

  1. Virtual camera not showing up

    • Verify the v4l2loopback module is loaded: lsmod | grep v4l2loopback
    • Check available video devices: v4l2-ctl --list-devices
    • Ensure you have the correct permissions to access /dev/video2
  2. Permission denied errors

    • Add your user to the video group: sudo usermod -a -G video $USER
    • Log out and back in for the group changes to take effect

System Information

This project has been tested with the following setup:

  • OS: Ubuntu 24.04 LTS
  • GPU: NVIDIA RTX 4060 Ti
  • Driver: 550.127.05
  • CUDA: 12.5
  • PyTorch: 2.5.1+cu121

Security Note

The virtual camera setup requires system-level modifications. Always verify the source of any kernel modules or system modifications before applying them. The provided configuration has been tested on Ubuntu 24.04 and should be used with caution on other systems.

Acknowledgements

Special thanks to Yondon Fu, the creator of ComfyStream, for building the foundation that made this project possible.

Incredibly grateful to Streamr Network for the grant support towards AI integration efforts for StreamrTV, enabling the development of real-time AI-enhanced video experiences.

About

A virtual camera for AI processed outputs from comfystream

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 41.9%
  • TypeScript 34.9%
  • JavaScript 19.0%
  • Shell 2.4%
  • CSS 0.7%
  • HTML 0.6%
  • Other 0.5%