Sonoff cam gen-2 implementation help needed

Hello community,
I just buy a new cam

SONOFF CAM GEN 2

It support RTSP.
Indeed I can set it up from the ewelink app and i give back these url from the app:

rtsp://USER:PASS@192.168.178.145:554/av_stream/ch0

I tought i can easilly implement it in my OH enviroment with the IPcamera binding that shuld support RTSP devices but i’m not able to see the stream but i got ERROR on the thing like in the image


HERE the same as the piture above but in CODE

UID: ipcamera:generic:6f1e1811fa
label: Sonoff Cam Esterno
thingTypeUID: ipcamera:generic
configuration:
  ffmpegInputOptions: -f mjpeg
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 192.168.178.145
  updateImageWhen: "0"
  mjpegUrl: ffmpeg
  gifPreroll: 1
  ffmpegLocation: /usr/bin/ffmpeg
  serverPort: 54322
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  port: 80
  snapshotUrl: ffmpeg
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ffmpegInput: rtsp://USER:PASS@192.168.178.145:554/av_stream/ch0
  gifOutOptions: -r 2 -filter_complex
    scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4
location: Esterno
channels:
  - id: startStream
    channelTypeUID: ipcamera:startStream
    label: Start HLS Stream
    description: Lower the delay to start casting the camera by creating the files
      non stop in case they are needed.
    configuration: {}
  - id: pollImage
    channelTypeUID: ipcamera:pollImage
    label: Poll Image
    description: This can be used to trigger snapshot updates when an external PIR,
      button or other form of sensor turns this channel ON.
    configuration: {}
  - id: image
    channelTypeUID: ipcamera:image
    label: Image
    description: Low frame rate image from your camera. Recommend this is NOT used
      unless you have large pollTime.
    configuration: {}
  - id: recordingGif
    channelTypeUID: ipcamera:recordingGif
    label: GIF Recording
    description: Indicates how long the recording will occur for and when the file
      is created, the channel will change to 0 by itself.
    configuration: {}
  - id: gifHistory
    channelTypeUID: ipcamera:gifHistory
    label: GIF History
    description: A history of the last GIFs created in a CSV formatted string.
    configuration: {}
  - id: gifHistoryLength
    channelTypeUID: ipcamera:gifHistoryLength
    label: GIF History Length
    description: How many GIFs are stored in the history.
    configuration: {}
  - id: recordingMp4
    channelTypeUID: ipcamera:recordingMp4
    label: MP4 Recording
    description: Indicates how long the recording will occur for and when the file
      is created, the channel will change to 0 by itself.
    configuration: {}
  - id: mp4History
    channelTypeUID: ipcamera:mp4History
    label: MP4 History
    description: A history of the last mp4 recordings created in a CSV formatted string.
    configuration: {}
  - id: mp4HistoryLength
    channelTypeUID: ipcamera:mp4HistoryLength
    label: MP4 History Length
    description: How many mp4 recordings are stored in the history.
    configuration: {}
  - id: lastMotionType
    channelTypeUID: ipcamera:lastMotionType
    label: Last Motion Type
    description: A string that contains the type of motion alarm that was last triggered.
    configuration: {}
  - id: ffmpegMotionControl
    channelTypeUID: ipcamera:ffmpegMotionControl
    label: Control FFmpeg Motion Alarm
    description: Enable/Disable the motion alarm and control the sensitivity.
    configuration: {}
  - id: ffmpegMotionAlarm
    channelTypeUID: ipcamera:ffmpegMotionAlarm
    label: FFmpeg Motion Alarm
    description: FFmpeg has detected motion.
    configuration: {}
  - id: externalMotion
    channelTypeUID: ipcamera:externalMotion
    label: External Motion
    description: Use any external sensor like a ZWave PIR sensor to flag that the
      camera has motion in its field of view.
    configuration: {}
  - id: thresholdAudioAlarm
    channelTypeUID: ipcamera:thresholdAudioAlarm
    label: Audio Alarm Threshold
    description: By moving this control you should be able to change how sensitive
      the audio alarm is to soft or loud noises.
    configuration: {}
  - id: audioAlarm
    channelTypeUID: ipcamera:audioAlarm
    label: Audio Alarm
    description: Audio has triggered an Alarm.
    configuration: {}
  - id: mjpegUrl
    channelTypeUID: ipcamera:mjpegUrl
    label: MJPEG URL
    description: A link you can use in openHAB/HABpanel to fetch a MJPEG video feed
      from the camera.
    configuration: {}
  - id: rtspUrl
    channelTypeUID: ipcamera:rtspUrl
    label: RTSP URL
    description: A link that the camera uses for RTSP.
    configuration: {}
  - id: imageUrl
    channelTypeUID: ipcamera:imageUrl
    label: Image URL
    description: A link you can use to fetch a static image from the camera.
    configuration: {}
  - id: hlsUrl
    channelTypeUID: ipcamera:hlsUrl
    label: HLS URL
    description: A link you can use in openHAB to cast video feeds.
    configuration: {}

logs says:

INFO	openhab.event.ThingStatusInfoChangedEvent	Thing 'ipcamera:generic:6f1e1811fa' changed from OFFLINE (COMMUNICATION_ERROR): FFmpeg Snapshots Stopped: Check that your camera can be reached. to ONLINE

INFO	openhab.event.ThingStatusInfoChangedEvent	Thing 'ipcamera:generic:6f1e1811fa' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): FFmpeg Snapshots Stopped: Check that your camera can be reached.

any one have some advise?
Is the binding configuration correct?

ps.
these link says that in other enviroment like HA has been already tested and OK

Link to italian abstract

Video of easy HA integration via RTSP generic stream

Streaming via VLC works with the RTSP url that I also insert in Openhab…but OH have problems to connect the cam. I did not understand what could be the problem

I think ‘snapshot url’ and ‘mjpeg url’ has to be blank

Ffmpeg is not a url… :man_shrugging:t3:
Did you tried without?
Greets

Ffmpeg onthat 2 fields is the default value if leave it empty…

Ah okay.

You need to post some TRACE level logs from the binding, the output from ffmpeg is hidden unless you enable the trace logging.

Hey Matt1,
thank you, is something I never do before.
I goes to log viever and i set level TRACE to openhab.event.ThingStatusInfoEvent.
Is it right?

as new output I have the following:

TRACE	openhab.event.ThingStatusInfoEvent	Received event of type 'ThingStatusInfoEvent' under the topic 'openhab/things/ipcamera:generic:6f1e1811fa/status' with payload: '{"status":"ONLINE","statusDetail":"NONE"}'
TRACE	openhab.event.ThingStatusInfoEvent	Received event of type 'ThingStatusInfoEvent' under the topic 'openhab/things/ipcamera:generic:6f1e1811fa/status' with payload: '{"status":"OFFLINE","statusDetail":"COMMUNICATION_ERROR","description":"FFmpeg Snapshots Stopped: Check that your camera can be reached."}'

Click on this picture and do it this way if you’re using the latest openHAB stable build, it has the log built into the UI now…

1 Like

Yes, ok, I manually add “org.openhab.binding.ipcamera” because was not on the list and new lines in log viewer are:

DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Binding has no snapshot url. Will use your CPU and FFmpeg to create snapshots from the cameras RTSP.
DEBUG	org.openhab.binding.ipcamera.internal.Ffmpeg	Starting ffmpeg with this command now: -f mjpeg -threads 1 -skip_frame nokey -hide_banner -i rtsp://Esterno:PASS@192.168.178.145:554/av_stream/ch0 -an -vsync vfr -q:v 2 -update 1 http://127.0.0.1:8080/ipcamera/6f1e1811fa/snapshot.jpg

TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	-vsync is deprecated. Use -fps_mode
TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	rtsp://Esterno:PASS@192.168.178.145:554/av_stream/ch0: Protocol not found
TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	Did you mean file:rtsp://Esterno:PASS@192.168.178.145:554/av_stream/ch0?

Update:
I follow the “instruction” writes on the logs

and now I get:

DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Binding has no snapshot url. Will use your CPU and FFmpeg to create snapshots from the cameras RTSP.
INFO	openhab.event.ThingStatusInfoChangedEvent	Thing 'ipcamera:generic:6f1e1811fa' changed from OFFLINE (COMMUNICATION_ERROR): FFmpeg Snapshots Stopped: Check that your camera can be reached. to ONLINE
DEBUG	org.openhab.binding.ipcamera.internal.Ffmpeg	Starting ffmpeg with this command now: -f mjpeg -threads 1 -skip_frame nokey -hide_banner -i file:rtsp://Esterno:PASS@192.168.178.145:554/av_stream/ch0 -an -fps_mode vfr -q:v 2 -update 1 http://127.0.0.1:8080/ipcamera/6f1e1811fa/snapshot.jpg
TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	file:rtsp://Esterno:PASS@192.168.178.145:554/av_stream/ch0: No such file or directory

I am pretty sure this is not the default setting, did you change this?
try making this blank as I am pretty sure your camera will be creating a single RTSP feed that is h264 and not in mjpeg format.

No idea where the file:rtsp came from. I recommend you delete the thing and create a new one leaving everything on the defaults. You should only need to provide the FFmpeg Input url, the user and the password and the IP. Also when providing the rtsp://Esterno:PASS@192.168. you can leave the user:pass out… Use this URL…

rtsp://192.168.178.145:554/av_stream/ch0

This way if you ever change your password it is only in 1 feild and I also believe it removes the password from the logs automatically for you.

1 Like

OMG
I made a new thing as you said
and
BOOM
image

Indeed I have to feed the ID:PASS on the URL but now works correctly.
Thank you very much…!!!