Android IP webcam failed to call service recording

I set up an android IP webcam integration according to the ‘full example’ of documentation (Android IP Webcam - Home Assistant)

Now I’m trying to create buttons in Lovelace to take a snapshot or start recording video and save it to my local folder. Snapshot is working fine, but video recording shows and error of “failed to call service, camera does not support record service”. It’s strange because I’m able to start video recording via http://IPADDRESS:PORT or using the camera video recording switch (switch.entrance_video_recording). What is wrong with my code?

type: horizontal-stack
cards:
  - type: button
    tap_action:
      action: call-service
      service: camera.snapshot
      service_data:
        entity_id: camera.entrance
        filename: /config/www/snapshot.jpg
    entity: camera.entrance
    icon: mdi:camera-iris
    name: Snapshot
  - type: button
    tap_action:
      action: call-service
      service: camera.record
      service_data:
        entity_id: camera.entrance
        filename: /config/www/recording.mp4
        duration: 30
    entity: camera.entrance
    icon: mdi:video
    name: Recording

Hi,

I’m having the exact same problem. Hopefully someone will post a solution for this.

I’ve found two theoretically working solution to overcome this issue (neither is nice and only one is working for me).

  1. Catch the stream with ffmpeg and save to your folder (it doesn’t work for me, but maybe helpful for others)
ffmpeg:
shell_command: 
  video_recording_ffmpeg: 'ffmpeg -i http://user:[email protected]:port/video -t 00:00:30 -y -c copy /config/www/recording.mp4'
  1. Create a rest command (start and stop recording) in the configuration.yaml, then you can call it as a service by pressing a button or a switch. Later an automation can save the recording to a local folder with HA downloader
## Rest command that start and stop video recording (when stopped the recording will be found on the android device)
rest_command:
  video_recording_start:
    url: 'http://user:[email protected]:port/startvideo?force=1'
    method: POST    
  video_recording_stop:
    url: 'http://user:[email protected]:port/stopvideo?force=1'
    method: POST

## If you call this service, it's going to save the recording (previously saved on the android device) into your HA local download folder (you have to specify the location first in the configuarion.yaml)
service: downloader.download_file
data:
  url: http://user:[email protected]:port/v//rec_2022-03-15_20-17.mp4
  filename: rec_2022-03-15_20-17.mp4

Unfortunately, if you want to automatically save the recordings, you have to know the exact name of the created mp4. In my case it is always ‘rec_yyyy-mm-y_hh-mm.mp4’. The time is equal to that when you pushed the start button.

1 Like

Thanks for this, I was able to use the shell command to record video but removed the -c argument to encode as mp4.

shell_command:
  ffmpeg_record_living_room_clip: ffmpeg -i http://192.168.1.178:8080/video -t 00:00:05 -y /media/recordings/living_room_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4

Now if I can only the the motion sensing to work with the Android IP Camera!

2 Likes

from what ive gathered the reason is because the stream service only works with x264/5 and not mjpeg streams.

if i run the command manually inside the container with a simple file name it works but as a shell command with the templated name i get the error. with the command quoted or not:

shell_command:
  ffmpeg_record_cory_cam: nohup ffmpeg -i http://user:[email protected]:8080/video -t 00:01:00 -y /media/recordings/cory_cam_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4 &

2022-06-06 13:29:59 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: nohup ffmpeg -i http://user:[email protected]:8080/video -t 00:01:00 -y /media/recordings/cory_cam_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4 &, return code: 1
NoneType: None

the .mp4 gets created in the dir, but its just 0 bytes:

-rw-r–r-- 1 root root 0 Jun 6 18:29 cory_cam_20220606-132959.mp4

1 Like

turns out the app does spit out RTSP streams. you can use a generic camera to then record that. ive opened a feature request to see if the RTSP streams can be added to the integration: Android ip webcam integration includes RTSP and ONVIF streams too

2 Likes