IP Camera Binding with ESP32 Cam

I want to set up an IP Camera Thing and use it to integrate an ESP32 Camera to my smart home.

I have set up the following thing and item:

Thing ipcamera:generic:AnetCam
[
    ipAddress="192.168.178.97",
    gifPreroll=1,
    snapshotUrl="http://192.168.178.97/capture",
    mjpegUrl="http://192.168.178.97:81/stream",
    ffmpegInputOptions="-f mjpeg",
    ffmpegOutput="/tmp/AnetCam/", 
	ffmpegInput="http://192.168.178.97:81/stream",
	ipWhitelist="DISABLE"
]
String AnetCam "Front Door" { channel="ipcamera:generic:AnetCam:hlsUrl" [ protocols="hls" ] }

From what I understand, I should now be able to use the URL http://192.168.178.29:9090/ipcamera/AnetCam/ipcamera.m3u8 to stream content using VLC. However nothing happens (http://192.168.178.97:81/stream works with VLC). When I call the URL in my browser it just downloads the m3u8 file.

It has the following content:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:2.000000,
ipcamera0.ts

There is a file /tmp/AnetCam/ipcamera0.ts on my server.

Am I missing something?

You should post the TRACE level log output as this will include the raw FFmpeg output in it that will show any errors and more importantly if you can reach 1.0x speed.

The problem will be your CPU needs to be able to TRANSCODE the mjpeg stream into h264 in realtime and not many CPU’s can do that in real time.

Also it really does not make much sense turning a low res and framerate stream into HLS, unless your wanting to cast the stream to a TV/chromecast, or google home hub.

If your wanting to do HLS, then its a good reason to buy a better camera that has h264 streams.

You can of course use this URL for the stream…

http://192.168.178.29:9090/ipcamera/AnetCam/ipcamera.mjpeg

The advantage of this over using the cameras direct URL, is that the camera probably can not stream to multiple tablets/phones/webpages at the same time, but the binding can handle that. Also if the camera drops off the wifi and comes back online, the mjpeg stream should still work via the binding, but will fail from the cameras direct URL.

1 Like

Thank you!

I don’t really know why I choose h264 - As you said it does not make much sense for the ESP. I know did the following and it worked:

String AnetCam { channel="ipcamera:generic:AnetCam:mjpegUrl" }

matt, is it also possible to do the gif creation / snapshotting from the ‘restreamed’ url?

It would be possible, just not sure if it is implemented to easily do that without creating a second camera thing pointing to the first. Perhaps try setting the ‘ffmpeg input’ url to the openHAB restreamed one as I have never tried or considered going that… I do not know why you would want to do that as the GIF can be created from the SNAPSHOTS by setting the gifPreroll=1 or higher. The esp32 can serve heaps of jpg snapshots, where it is limited to only 1 stream.

  • recording gif
  • ffmpeg based alarms. (you can supply a separate URL to use as a source for this already)

Those will try to open their own stream each, so it may very well work if you just set the ‘ffmpeg input’ url to the openHAB restreamed one. If you give it a try, let me know the result either way. If ffmpeg is getting a mjpeg based stream, you do need to change a config ffmpegInputOptions="-f mjpeg"