We output RTSP stream to LG webOS TV

Android has the ability to output video to the frame using Pipup, but webOS does not have such a program, and it is also impossible to output video from the camera using service: camera.play_stream. It is also impossible to play videos with an RTSP stream through the built-in browser, since there is no support for h264/265 codecs. I found how to display video from the camera on webOS without installing third-party software on LG TV. To output video from the camera to LG TV, we will need an installed Agent DVR and we will use the Agent DVR API.

Read more about the AgentDVR API here

Below is an example of how to specify commands. We specify the IP address of the AgentDVR server, in my case it is 192.168.1.50:8090

http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0

where:

  • http://192.168.1.50:8090 - AgentDVR server address
  • video.mjpg - we broadcast the video
  • oid=1 - camera number, where each camera has its own number 1.2.3.4.5 … Specify the number of the camera we need. If you need to output camera 3, then specify oid=3
  • size=1920x1080 - resolution of the output image
  • backColor=0,0,0 - background color, I specified black color

Knowing the path of AgentDVR video streaming, we can add a url to the webasto.command service

service: webostv.command
data:
  entity_id: media_player.smart_tv
  command: system.launcher/open
  payload:
    target: >
      http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0
alias: Open a browser with a camera

Now the built-in browser will start on our TV and a window with a video camera with minimal delay (webrtc) will open

I use the EZVIZ CS-DP2K video viewer, which has an RTSP stream and can be added to AgentDVR. I note that RTSP works when the camera turns on, and when the camera turns off, then RTSP turns off. But you can turn off auto sleep and RTSP will always work. To do this, you need to install EZVIZ integration from the GUI and turn off auto sleep, after that RTSP will always work, but the battery charge level will quickly decrease, so you need to take care of constant power supply. I connected the video eye to a constant power supply by pulling the wire inside the door to the video eye

Photo of the internal wiring to the video eye




Next, we create automation that will open the browser on TV when an incoming call is made to the door. I use the “Last Notification” sensor as a trigger. Since there is no incoming call sensor in the EZVIZ integration for the EZVIZ CS-DP2C video eye, and I don’t want to disassemble and redo the video eye, I used the “Last Notification” sensor in the Home Assistant mobile application and specified only EZVIZ.

How to turn on the "Last Notification" sensor




Screenshot of automation

alias: "Video eyes: Broadcast on TV in the kitchen"
description: >-
  When an incoming call is made to a video eye, a browser will open on the TV with
  a real-time video stream tab for N seconds, while
  saving the current TV status to the history. After that, the window on the TV with the camera will close 
  and TV will return by history
trigger:
  - platform: state
    entity_id:
      - sensor.tablet_sm_t580_last_notification
    to: Someone is ringing the doorbell
    alias: Someone is ringing the doorbell
condition: []
action:
  - service: scene.create
    data:
      scene_id: kitchen_tv_lg_history
      snapshot_entities: media_player.lg_tv_kitchen
    alias: Save to History
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    alias: 1 second delay
  - service: webostv.command
    data:
      entity_id: media_player.lg_tv_kitchen
      command: system.launcher/open
      payload:
        target: >
          http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0
    alias: Open a browser with a camera
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
    alias: Delay of 20 seconds
  - service: scene.turn_on
    target:
      entity_id: scene.kitchen_tv_lg_history
    metadata: {}
    alias: Restore from History
mode: single
Текст на русском (Text in Russian)

У андроид есть возможность выводить видео в рамку используя Pipup, а у WebOS такой программы нет, а также нельзя вывести видео с камеры используя service: camera.play_stream. Через встроенный браузер также нельзя воспроизводить видео с потоком RTSP, так как нет поддержки кодеков h264/265. Я нашел как на WebOS можно вывести видео с камеры, при этом не устанавливая на ТВ LG сторонний софт. Для вывода видео с камеры на ТВ LG нам понадобится установленный Agent DVR и будем использовать API Agent DVR.

Подробности про API AgentDVR читаем здесь

Ниже пример как нужно указывать команды. Указываем IP адрес сервера AgentDVR, в моем случае это 192.168.1.50:8090

http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0

где:

  • http://192.168.1.50:8090 - адрес сервера AgentDVR
  • video.mjpg - транслируем видео
  • oid=1 - номер камеры, где у каждой камеры есть свой номер 1.2.3.4.5 … Указываем номер нужной нам камеры. Если нужно вывести камеру 3, то указываем oid=3
  • size=1920x1080 - разрешение выводимой картинки
  • backColor=0,0,0 - цвет фона, я указал черный цвет

Зная путь видеостриминга AgentDVR, можем в службу webostv.command добавить url

service: webostv.command
data:
  entity_id: media_player.smart_tv
  command: system.launcher/open
  payload:
    target: >
      http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0
alias: Открыть браузер с камерой

Теперь у нас на ТВ запустится встроенный браузер и откроется окно с видеокамерой с минимальной задержкой (webrtc)

У меня используется видеоглазок EZVIZ CS-DP2C у которого есть RTSP поток и можно добавить в AgentDVR. Отмечу, что RTSP работает тогда, когда включается камера, а как камера выключается, то RTSP выключается. Но можно выключить авто сон и RTSP будет работать всегда. Для этого нужно установить интеграцию EZVIZ из GUI и выключить auto sleep, после этого RTSP будет работать всегда, но будет быстро сокращаться уровень заряда аккумулятора, поэтому нужно озаботиться о постоянном питании. Я подключил видеоглазок к постоянному питанию, протянув провод внутри двери к видеоглазку

Фото внутренней проводки к видеоглазку




Далее создаем автоматизацию, которая будет при входящем вызове на дверь открывать браузер на ТВ. В качестве триггера я использую сенсор “Последнее уведомление”. Так как в интеграции EZVIZ для видеоглазка EZVIZ CS-DP2C нет сенсора входящего вызова, а разбирать и переделывать видеоглазок не хочется, то я использовал в мобильном приложении Home Assistant сенсор “Последнее уведомление” и указал только ezviz.

Как включить сенсор "Последнее уведомление"




Скриншот автоматизации

alias: "Видеоглазок: Трансляция на ТВ на кухне"
description: >-
  При входящем вызове на видеоглазок, на телевизоре откроется браузер со
  вкладкой видеопотока видеоглазка в реальном времени на N секунд, при этом
  сохранив в историю текущий статус ТВ. После, окно на ТВ с камерой закроется и
  ТВ вернется по истории
trigger:
  - platform: state
    entity_id:
      - sensor.tablet_sm_t580_last_notification
    to: Кто-то звонит в дверь
    alias: Кто-то звонит в дверь
condition: []
action:
  - service: scene.create
    data:
      scene_id: kitchen_tv_lg_history
      snapshot_entities: media_player.lg_tv_kitchen
    alias: Сохранить в историю
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    alias: Задержка в 1 секунду
  - service: webostv.command
    data:
      entity_id: media_player.lg_tv_kitchen
      command: system.launcher/open
      payload:
        target: >
          http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0
    alias: Открыть браузер с камерой
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
    alias: Задержка в 20 секунд
  - service: scene.turn_on
    target:
      entity_id: scene.kitchen_tv_lg_history
    metadata: {}
    alias: Восстановить из истории
mode: single
7 Likes

This is awesome, thanks for posting! I’ve never heard of agent dvr before, is it really required for this to work? Seems like you’re ultimately just using an mjpg stream, couldn’t you just get that off the camera directly?

I tried Agent DVR, Frigate, Go2rtc, it works best in Agent DVR, there are no delays in the video, Frigate has delays, but I didn’t succeed with Go2rtc, the links open, but the picture doesn’t show except frame, it’s a static picture and after that my TV freezes. Agent DVR takes all the load on itself and does not load the TV stream

Agent DVR HTTP API option

Specifying the path to the camera in Agent DVR

http://192.168.1.50:8090/video.mjpg?oid=3&size=1920x1080&maintainAR=true&backColor=0,0,0

A variant of the Frigate HTTP API. Read more here

Specifying the path to the camera in Frigate

http://192.168.1.50:5000/api/hall?fps=24&h=1080

Go2rtc. Read more about Go2rtc here

streams:
  cam_enter: 
    - rtsp://xxx:[email protected]:554/stream1
    - ffmpeg:rtsp://xxx:[email protected]:554/stream1#video=mjpeg
4 Likes

Hello, sorry for the silly question, but where to get the “IP address of the AgentDVR server”, where exactly it is written?

And also please tell me if I understand correctly, that after AgentDVR installation all further actions are made in the terminal of webOS Dev Manager installed on the computer?

Agent DVR is installed in the server part, for example in docker, there is also an addon Agent DVR for Home Assistant. The IP address of Agent DVR is the one where it stands, for example, you have Agent DVR on a server with an IP address of 192.168.1.80 and let’s say Home Assistant is also there, only the ports are different. To connect to Agent DVR, specify http://192.168.1.80:8090

How to set up video output from the camera to LG TV via go2rtc?

Create a go2rtc.yaml file in the /config folder

Adding to go2rtc.yaml

Attention. Each camera has its own RTSP address. See your camera’s documentation. You can use the link generator for your camera at this link I specify the address of the RTSP stream from the Eufy Indoor Cam 2K Pan & Tilt T8410 camera and its RTSP address looks like this: rtsp://user:password@IP/live0 .

streams:
  any_name:
    - ffmpeg:rtsp://user:password@IP/live0#video=mjpeg

any_name this is the name of your camera or specify any understandable name and this name will be displayed here (highlighted in the screenshot)

image

user - We specify the login. The login can be seen in the camera settings
password - Specify the password. The password can be seen in the camera settings
IP - Specify the IP address of your camera


To open the TV in the browser, we use such a link where we specify the IP address of go2rtc and at the end, instead of any_name, we specify the name of the camera

http://IP:1984/api/stream.mjpeg?src=any_name

You can open a video stream in a browser on TV with this command

service: webostv.command
data:
  entity_id: media_player.lg_tv_kitchen
  command: system.launcher/open
  payload:
    target: |
      http://IP:1984/api/stream.mjpeg?src=any_name
alias: Открыть браузер с камерой
Текст на русском (Text in Russian)

Как настроить вывод видео с камеры на ТВ LG через go2rtc?

Создаем в папке /config файл go2rtc.yaml

Добавляем в go2rtc.yaml

Внимание. У каждой камеры свой адрес RTSP. Смотрите в документации своей камеры. Вы можете воспользоваться генератором ссылок для вашей камеры по этой ссылке. Я указываю адрес RTSP потока от камеры Eufy Indoor Cam 2K Pan & Tilt T8410 и у нее RTSP адрес выглядит так: rtsp://user:password@IP/live0.

streams:
  any_name:
    - ffmpeg:rtsp://user:password@IP/live0#video=mjpeg

any_name это название вашей камеры или укажите любое понятное название и это имя будет отображаться здесь (выделено на скриншоте)

image

user - Указываем логин. Логин можно увидеть в настройках камеры
password - Указываем пароль. Пароль можно увидеть в настройках камеры
IP - Указываем IP адрес своей камеры


Чтобы открыть в браузере ТВ используем такую ссылку, где мы указываем IP адрес go2rtc и в конце вместо any_name указываем имя камеры

http://IP:1984/api/stream.mjpeg?src=any_name

Открыть видеопоток в браузере на ТВ можно такой командой

service: webostv.command
data:
  entity_id: media_player.lg_tv_kitchen
  command: system.launcher/open
  payload:
    target: |
      http://IP:1984/api/stream.mjpeg?src=any_name
alias: Открыть браузер с камерой
1 Like

Great guide, thank you!
I’ve a question about the EZVIZ CS-DP2C. In the guide you say that you was able to use the RTSP of this device. I’ve a CP4 and a DP1 and I was never able to enable the RTSP of the cameras. Even online no one was able to do it. Do you have some info about how to enable it?
Thanks

There is a forum EZVIZ DP1/DP1S/DP1C/DP2/DP2C/DP2S Video Eye, maybe you can find answers there?

Try this link for DP1
rtsp url: rtsp://ip:554/mpeg4/ch01/main/av_stream

Thank you! Not seems to work though. Maybe I should try to get a DP2C

Keep in mind that the latest firmware blocks access to RTSP and you need to rollback. You can contact EZVIZ technical support. I have disabled automatic updates in the EZVIZ application. I have EZVIZ CS-DP2C and have firmware version V5.3.3 build 220516 where RTSP works

rtsp://login:password@IP:554/mpeg4/ch01/sub/av_stream

Thank you! I found that firmware on a discussion on github. Tomorrow I should get the DP2C, I’ll see what firmware is shipped with