logoalt Hacker News

Offloading FFmpeg with Cloudflare

18 pointsby heftykoolast Tuesday at 8:41 AM11 commentsview on HN

Comments

Doohickey-dyesterday at 9:59 PM

You can do this all in fly.io, no cloudflare container needed.

The whole selling point of fly is lightweight and fast VMs that can be "off" when not needed and start on-request. For this, I would:

Set up a "peformance" instance, with auto start on, and auto-restart-on-exit _off_, which runs a simple web service which accepts an incoming request, does the processing and upload, and then exits. All you need is the fly config, dockerfile, and service code (e.g. python). A simple api app like that which only serves to ffmpeg-process something, can start very fast (ms). Something which needs to load e.g. a bigger model such as whisper can also still work, but will be a bit slower. fly takes care of automatically starting stopped instances on an incoming request, for you.

(In my use case: app where people upload audio, to have it transcribed with whisper. I would send a ping from the frontend to the "whisper" service even before the file finished uploading, saying "hey wake up, there's audio coming soon", and it was started by the time the audio was actually available. Worked great.)

show 2 replies
anesxvitoyesterday at 11:39 PM

Smart approach to offloading heavy computation. The pattern of keeping the core logic local but delegating expensive operations is underrated — works for media processing, works for CI pipelines.

thadkyesterday at 10:14 PM

Ffmpeg.WASM is really good and might manage all these steps before even uploading.

show 1 reply
detuksyesterday at 10:10 PM

I would not suggest using cloudflare containers for ffmpeg. Feels like it is the nost expensive product they have. Queue to aws spot instances or just have dedicated hetzner machine

show 2 replies
DanielHByesterday at 10:26 PM

Not really related to the topic, but I recently set up a baby-cam with ffmpeg by just telling ffmpeg to stream to the broadcast address on my home network and I can now open the stream from VLC on any device in the household.

A very heavy-handed solution, but super simple. A single one-liner. Just thought to share a weird trick I found.

show 1 reply