Easily Trim or Speed up videos with a click, and download videos from social media with cobalt.
This project was mostly for fun/experimentation, so I'm open-sourcing it, just in case you're curious about the code or want to take inspiration for your own projects.
The frontend (plain HTML/CSS & JS) is deployed on Cloudflare Pages using Vite for the build process.
The backend (written in Go) is dockerized and deployed on Fly.io.
- Trimming is implemented with
ffmpeg.wasm, allowing the browser to process the video client-side. I wanted to tryffmpeg.wasm, and overall, it's really cool—but it still has room for improvement. - Speedup is done server-side with
ffmpeg.
It works only locally, if you want to run on your computer, follow the instructions in the next section.
This was the most fun feature to implement! I learned a lot about building a custom backend segmentation system by leveraging existing models (thanks to Claude for the code).
Serving the segmentation backend local API with FastAPI.
It uses Docker, so install it if you don’t have it already.
- Run docker using whatever you like (I suggest OrbStack instead of Docker desktop)
- In the root dir run
docker-compose up --build - (Optional but Recommended if you have a NVIDIA GPU) Install the NVIDIA Container Toolkit and start the stack with
docker compose -f docker-compose.yml -f docker-compose.gpu.yml up --buildto expose CUDA inside thesam2segcontainer - Open the frontend via
https://localhost:5173 - Enjoy
It was implemented using Cloudflare Workers and Cloudflare Queues for asynchronous processing. However currently it's not working (and discontinues) since a lot has changed.
Here's a rough diagram of the whole (old) async workflow (shoutout to moni for the help):
This was discontinued because:
- It was a setup built to learn how async processing/workflow works
- Renting a good GPU and keep it running + CloudFlare subscription = too expensive right now
I hope someone finds this messy source code useful :)