# IP Camera Binding with ESP32 Cam

**URL:** <https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152>\
**Category:** Items & Sitemaps\
**Tags:** esp32, ipcamera\
**Created:** [September 20, 2022, 8:39pm UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152 "2022-09-20T20:39:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tdog](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@Tdog](https://community.openhab.org/u/Tdog)\
**Post date:** [September 20, 2022, 8:39pm UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152/1 "2022-09-20T20:39:39Z")

</div>

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:

```auto
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"
]

```

```auto
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](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](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:

```auto
#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?

---

<div class="post-metadata">

**Author:** ![matt1](https://community.openhab.org/user_avatar/community.openhab.org/matt1/32/19930_2.png) [@matt1](https://community.openhab.org/u/matt1)\
**Post date:** [September 21, 2022, 3:14am UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152/2 "2022-09-21T03:14:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tdog](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@Tdog](https://community.openhab.org/u/Tdog)\
**Post date:** [September 21, 2022, 6:11pm UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152/3 "2022-09-21T18:11:04Z")

</div>

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" }`

---

<div class="post-metadata">

**Author:** ![maDDin1338](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/f9ae1b/32.png) [@maDDin1338](https://community.openhab.org/u/maDDin1338)\
**Post date:** [September 25, 2022, 1:22pm UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152/4 "2022-09-25T13:22:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matt1](https://community.openhab.org/user_avatar/community.openhab.org/matt1/32/19930_2.png) [@matt1](https://community.openhab.org/u/matt1)\
**Post date:** [September 26, 2022, 10:59am UTC](https://community.openhab.org/t/ip-camera-binding-with-esp32-cam/139152/5 "2022-09-26T10:59:40Z")

</div>

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"`
