soyersoyer / fmp4streamer

Fmp4streamer streams your V4L2 camera directly to any browser and media player as MP4 (H264).
Apache License 2.0
80 stars 7 forks source link

Allow camera to be turned on/off #3

Closed lestrozi closed 2 years ago

lestrozi commented 2 years ago

I'm thinking about using this for a baby monitor, and I don't need the camera on the whole time. I also have single-client access.

So my idea was to only access the camera when a client is connected.

I tried playing with it a bit and I naively thought that creating/destroying the camera thread inside elif on line 145 would do, but of course the fd needs to be closed/reopened, and it doesn't work like that. Also, closing it is not so simple because it would need to signal the main_loop to stop, wait for it to stop using the device file, and then close it.

Any thoughts on how I could approach this? Or would you consider offering a "disconnect camera when no user is connected" (which is probably much simpler for single-client use)?

Thanks

soyersoyer commented 2 years ago

Good idea! It's better when it's green! Implemented in v3.4.0 and enabled by default.