Back to notes

The HD was in my pocket

For our church service livestream, we film with a phone. DroidCam sent it to OBS in low resolution, with its text on the picture, and wanted one ad per hour for Full HD. So I built my own app: Phone Cam.

At church, I run the livestream of the service. We don’t have much equipment, so we make do with what we have: the camera is a phone.

Its picture goes into OBS, the software that puts the livestream together and broadcasts it from the computer. To connect the two, everyone recommends the same app: DroidCam.

I install it. The picture arrives in low resolution, with DroidCam’s text stuck on it. So at every livestream, I’d look up how to crop the picture in OBS to push that text out of the frame. And I’d lose a piece of what we were filming along the way.

Full HD? DroidCam unlocked it for one hour in exchange for an ad. Or you had to subscribe. One hour later, another ad.

The phone films in Full HD, though. The sharp picture already existed, a few metres from the computer. I was just being asked to pay, in money or in ads, for it to reach OBS.

Right. I decided to build my own app. It’s called Phone Cam.

How does DroidCam work?

Before writing a single line, I looked at how DroidCam does it. There are two pieces: an app on the phone, which films and sends the picture, and a small plugin in OBS, which receives it and shows it like a real camera. In between, Wi-Fi or a USB cable.

The phone app is closed. The OBS plugin’s code, on the other hand, is public. Reading it, I understood how the pictures travel from one end to the other.

Picture a delivery service.

The phone is the sender. It films thirty pictures a second. A raw Full HD picture is too heavy to travel fast, so it compresses it, a bit like folding a shirt so it fits in a suitcase. Phones have a chip made just for that.

The Wi-Fi (or the USB cable) is the road. Each parcel leaves with a label: the time the picture was taken and the size of the package. Without a label, the receiver would have to guess where one parcel ends and the next begins, and it would lose time waiting to be sure.

The plugin in OBS is the receiver. It unpacks the parcels and puts each picture on screen, in order. If the parcels fall behind and start piling up, it drops the ones waiting and starts again from the next complete picture, so the livestream stays live.

Thirty parcels a second, for a whole service. The slightest delay shows: the picture jumps.

Phone Cam keeps that two-piece split. Everything else, I had to choose.

Flutter, React Native or Kotlin?

First choice: the app’s language. I already know React Native and Flutter. With them, I write one app for Android and iPhone. I would have saved time.

Except here, performance is what counts. React Native and Flutter work a bit like an interpreter between your code and the phone. For a form or a product list, nobody notices the interpreter. But to talk to the camera and the chip that packs the pictures, they have to go through Android’s native code anyway. The interpreter adds a layer, and gives me nothing.

So I went with Kotlin, Android’s native language. It talks directly to the camera and the chip, and I can tune every step of the trip myself.

I was starting from almost zero. It took longer.

And the OBS plugin, in C++?

OBS plugins are written in C or C++. I had never touched C.

I worked with Claude, an AI assistant. I explained what the plugin had to do: read the labels, unpack the pictures, drop the late parcels, reconnect on its own if the phone disappears. It wrote the code. I read it, installed the plugin in OBS, tested with my phone and measured. When something was off, I came back with what I had seen.

I still haven’t learned C. What I did know was what I wanted to build and how to check that it worked.

The Wi-Fi, the stopwatch and the clap

With the cable, it worked fairly quickly. The phone’s picture appeared on the computer, sharp, in 1080p, with no text on it.

So I unplugged the cable. Nothing. The phone was sending, the computer was waiting, and no parcel arrived.

I looked for the bug in my code for a while. There wasn’t one. The shared Wi-Fi where I work keeps devices apart: everyone can go out to the Internet, but nobody is allowed to knock on their neighbour’s door. For my delivery guy, it was a building where every door had been bricked up. The fix was dumb: the computer creates its own little Wi-Fi, and the phone joins it.

Next, the delay. When someone moves their hand in front of the camera, it has to move on screen at the same moment. Otherwise it looks like bad dubbing.

To measure it, I filmed a stopwatch running on my screen, and compared the real one with the one showing in OBS. A bit under two tenths of a second apart. You might blame the network or the plugin. The measurements said otherwise: the computer unpacked each picture in five milliseconds. Most of the delay happened inside the phone, between the moment the sensor sees the light and the moment the parcel is ready to leave.

I tried several settings. Nothing moved. That’s the speed of this chip, in this phone, and my code can’t do anything about it.

Then I added the microphone. New problem: the sound arrived before the picture. Sound leaves almost right away, unpacked, while each picture first has to go through the chip that compresses it. The lips moved after the voice.

I had to hold the sound back just enough for it to come out with the right picture. To check, I did what they do in film: I clapped my hands in front of the camera, and watched whether the sound landed exactly when my hands met.

It landed at the right moment.

Can I try it?

Yes. Phone Cam runs on Android today, in Full HD, with sound, no text on the picture, no ads and no subscription.

There are two ways to connect the phone to the computer: Wi-Fi, or a USB cable. On the stopwatch, Wi-Fi turned out to be as fast as the cable, and it’s the simplest: install the app, type the address it shows into OBS, and you’re live. The cable works too, but it needs a developer option turned on in the phone and a small Android tool installed on the computer.

One more detail: over Wi-Fi, the phone shows a six-digit code. You type it once in OBS, and only that computer receives the picture. Your network neighbour can’t watch your livestream before everyone else. Over USB, no code needed: the cable already proves it’s your computer.

Everything is free and open source:

iPhone will come later.

At church, nothing left to crop, no more ad every hour.