No internet connection
  1. Home
  2. Technical Support

How can I feed the Tinypilot h264 stream into a media proxy

By @anders
    2024-01-17 12:07:21.507Zassigned to
    • @david

    I've got a use case where people at a central office location wants to have view only h264 streams from Tinypilot devices deployed in remote locations with metered internet (Starlink). We have a working implementation for that using RTSP cameras feeding into mediamtx media proxy (https://github.com/bluenviron/mediamtx).

    The media proxy supports multiple clients in the office while only a single stream per remote location is being transmitted on the metered internet link.

    Is there any way I can configure the Tinypilot to serve its h264 stream at a configurable port and stream address? I.e. wheps://tinypilot:443/h264.sdp , rtsp://tinypilot:554/h264.sdp or similar?

    • 6 replies
    1. A
      @anders
        2024-01-18 12:03:13.414Z

        See there's a janus configuration for ws_ip pointing to localhost/127.0.0.1 port 48002. Would changing this to 0.0.0.0 potentially make the stream accessible remotely? WebRTC is quite new to me, so sorry for the fumbling here.

        1. In reply toanders:
          David @david2024-01-18 12:35:20.423Z

          Hi @anders, thanks for your question!

          I don't know of anyone that has done anything like this with their TinyPilot.

          I'm not sure if just altering the Janus config will work or not, but you're welcome to edit any files on your TinyPilot to test whether any of your ideas work. Although I'd recommend making a backup of the original files, just in case.

          We're discussing this internally, so I'll be able to bring you an update on potential solutions soon.

          Please feel free to add more details or questions in the meantime.

          1. In reply toanders:
            David @david2024-01-19 12:30:52.099Z

            Thanks for your patience with this, @anders. I have a couple of questions about your use case.

            Do you need to simultaneously use the TinyPilot as normal and stream at the same time? Or do you only need to stream via the media proxy? I took a look at mediamtx, and it looks like there may be some simpler options if you only need to stream.

            1. A@anders
                2024-01-19 14:51:31.160Z

                Hi @david, no worries, this is a bit of a corner case I guess. We're happily using a large number of TinyPilots for the regular interactive use case at many sites in our company - really appreciate the well packaged product and its ease of use.

                For the case in question, we don't need to operate the TinyPilot in normal mode as long as we can retain the simplicity of having the view-only stream displayed in a web-browser (with a preset low framerate and low bitrate, similar to how it's set in /home/tinypilot/settings.yml). Looks like the option of serving web browsers directly has been stabilized pretty well recently in mediamtx so it could be worth a try.

                Which simpler options for getting the TinyPilot h264 stream into mediamtx were you thinking of?

                1. In reply todavid:
                  A@anders
                    2024-01-22 09:08:29.389Z

                    @david, mediamtx_v1.4.2_linux_arm64v8 appears to be running fine locally on the TinyPilot. I've attempted a couple of mediamtx whep URL paths to 4800x ports by trial and error but can't quite get there.

                    1. David @david2024-01-22 13:33:25.337Z

                      Thanks for the updates, @anders!

                      If you only need a view-only stream via your proxy, you might be able to publish your TinyPilot's video stream using ffmpeg, mediamtx's generic webcam option, or with mediamtx's RaspberryPi camera option.

                      Based on the mediamtx documentation, it looks like the generic camera option is the simplest here if you already have mediamx installed. I believe TinyPilot's capture device is /dev/video0, so from what I understand, you should be able to copy the documentation's instructions for publishing using a generic web cam for an rtsp stream. You may need to install ffmpeg first.

                      Since TinyPilot's streaming software normally uses /dev/video0, you will need to stop TinyPilot's ustreamer service for access to the capture device (sudo service ustreamer stop). You might also need to add your user to the video group (sudo usermod -aG video "${USER}") for the correct permissions.

                      I hope this helps! Please keep me updated and let me know if you have any questions.