Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help needed: how to transcode home assistant camera entity (series of images) to h264. #1348

Open
tonysprenk opened this issue Sep 11, 2024 · 10 comments
Labels
question Further information is requested

Comments

@tonysprenk
Copy link

I thought I could just do:

streams: 
 camera.x40_ultra_complete_map: ffmpeg:{output}#video=h264

But then I get an error. What am
I doing wrong?

@AlexxIT AlexxIT added the question Further information is requested label Sep 11, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Sep 11, 2024

If you talking about mjpeg camera - it's not supported. Because it doesn't have a stream.

@tonysprenk
Copy link
Author

I want to add the map from my robot vacuum cleaner to HomeKit. The map in home assistant is a camera component. When I add it to HomeKit with the HomeKit integration the preview image works but the stream does not. In home assistant I have an error saying that there is no stream.

I was hoping that go2rtc could transcode the vacuum cleaner map camera component to h264.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 11, 2024

You repeated what I said. MJPEG camera in Hass is not a stream.
You can get a MJPEG link from Hass, add a long live token to it, and use that as a source for go2rtc.
You can find the link in the browser debug menu or ask around on the Hass forums.

@tonysprenk
Copy link
Author

Ok I have done that but the h264 stream is not working. This my config:

streams: 
 camera.x40_ultra_complete_map: "http://homeassistant.local:8123/api/camera_proxy_stream/camera.x40_ultra_complete_map#header=Authorization: Bearer xxxx"

I get this error when streaming h264:

Webrtc/offer: streams: codec not matched: JPEG => h264, ......

Thank you for the help so far and any further insights.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 12, 2024

You should setup transcoding

@tonysprenk
Copy link
Author

With this config:

streams:
 Map: 
  - "http://homeassistant.local:8123/api/camera_proxy_stream/camera.x40_ultra_complet_map#header=Authorization: Beare xxx"
  -  ffmpeg:Map#video=h264

I get the following error:

10:02:31.664 PM	error	undefined error=streams: exec/rtsp
[out#0/rtsp @ 0x7f8d2f4f00] Output file does not contain any stream
Error opening output file rtsp://127.0.0.1:8554/ab29e4cbf5edb947487550b7caf09bdf.
Error opening output files: Invalid argument
caller=github.com/AlexxIT/go2rtc/internal/hls/ws.go:28

Any suggestions? thanks for the help so far.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 16, 2024

Are you sure this stream is currently running in MJPEG format?

@tonysprenk
Copy link
Author

I assume so because I'm accessing it through the home assistant API camera proxy. And opening the original stream in go2rtc works fine. Where it says MJPEG as the source. image

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 16, 2024

Go to go2rtc WebUI > links page for your stream.
Try to open RTSP for this stream for example in VLC.

Also you can copy MJPEG stream link and use it as input for ffmpeg source. Because by default it will try to use RTSP as input.

@tonysprenk
Copy link
Author

tonysprenk commented Sep 19, 2024

I have come to find out that the source is a series of images (as you mentioned before) in the PNG format. This FFMPEG command works in terminal:

ffmpeg -re -loop 1 -headers "Authorization: Bearer long_lived_access_token" -i "http://homeassistant.local:8123/api/camera_proxy/camera.x40_ultra_complete_map" -vf "fps=1" -vcodec libx264 -r 15 -pix_fmt yuv420p output.mp4

How can I use it in go2rtc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants