├── Dockerfile.template
├── docker-compose.yml
├── balena.yml
├── start.sh
├── LICENSE
└── README.md
/Dockerfile.template:
--------------------------------------------------------------------------------
1 | FROM balenalib/%%BALENA_MACHINE_NAME%%-node
2 |
3 | # Install dependencies
4 | RUN install_packages build-essential
5 |
6 | WORKDIR /usr/src/app
7 |
8 | # This will copy all files in our root to the working directory in the container
9 | COPY . ./
10 |
11 | # Enable udevd so that plugged dynamic hardware devices show up in our container.
12 | ENV UDEV=1
13 |
14 | # server.js will run when container starts up on the device
15 | CMD ["/bin/bash", "/usr/src/app/start.sh"]
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 | services:
3 | server:
4 | privileged: true
5 | build: .
6 | environment:
7 | - STREAM_DESTINATION_IP
8 | - STREAM_DESTINATION_PORT
9 | - WIDTH
10 | - HEIGHT
11 | - FRAMES_PER_SECOND
12 | - BITRATE
13 | - ROTATION
14 | - FLIP_HORIZONTAL
15 | - FLIP_VERTICAL
16 | - INTRA_REFRESH_PERIOD
17 | - METERING_MODE
18 | - EXPOSURE_MODE
19 | - DRC
20 | - SHARPNESS
21 | - BRIGHTNESS
22 | - CONTRAST
23 | - SATURATION
24 | - ISO
25 | - IMAGE_EFFECT
26 | - AUTO_WHITE_BALANCE_MODE
27 | - H264_PROFILE
28 |
--------------------------------------------------------------------------------
/balena.yml:
--------------------------------------------------------------------------------
1 | repoUrl: "https://github.com/hotsparklab/raspberry-pi-udp-camera"
2 | applicationConfigVariables:
3 | - BALENA_HOST_CONFIG_start_x: 1
4 | - BALENA_HOST_CONFIG_gpu_mem_256: 192
5 | - BALENA_HOST_CONFIG_gpu_mem_512: 256
6 | - BALENA_HOST_CONFIG_gpu_mem_1024: 448
7 | applicationEnvironmentVariables:
8 | - STREAM_DESTINATION_IP: YOUR_RECEIVING_PC_LOCAL_IP
9 | - STREAM_DESTINATION_PORT: 5001
10 | - WIDTH: 1280
11 | - HEIGHT: 720
12 | - ROTATION: 0
13 | - FLIP_HORIZONTAL: ""
14 | - FLIP_VERTICAL: ""
15 | - FRAMES_PER_SECOND: 30
16 | - INTRA_REFRESH_PERIOD: 60
17 | - BITRATE: 2500000
18 | - METERING_MODE: average
19 | - EXPOSURE_MODE: fixedfps
20 | - DRC: off
21 | - SHARPNESS: 0
22 | - BRIGHTNESS: 50
23 | - CONTRAST: 0
24 | - SATURATION: 0
25 | - ISO: 0
26 | - IMAGE_EFFECT: none
27 | - AUTO_WHITE_BALANCE_MODE: auto
28 | - H264_PROFILE: high
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | # Use provided environment variables or defaults.
2 | WIDTH=${WIDTH:=1280}
3 | HEIGHT=${HEIGHT:=720}
4 | INTRA_REFRESH_PERIOD=${INTRA_REFRESH_PERIOD:=60}
5 | FLIP_HORIZONTAL=${FLIP_HORIZONTAL:=""}
6 | FLIP_VERTICAL=${FLIP_VERTICAL:=""}
7 | ROTATION=${ROTATION:=0}
8 | FRAMES_PER_SECOND=${FRAMES_PER_SECOND:=30}
9 | BITRATE=${BITRATE:=2500000}
10 | METERING_MODE=${METERING_MODE:="average"}
11 | EXPOSURE_MODE=${EXPOSURE_MODE:="fixedfps"}
12 | DRC=${DRC:="off"}
13 | SHARPNESS=${SHARPNESS:=0}
14 | BRIGHTNESS=${BRIGHTNESS:=50}
15 | CONTRAST=${CONTRAST:=0}
16 | SATURATION=${SATURATION:=0}
17 | ISO=${ISO:=0}
18 | IMAGE_EFFECT=${IMAGE_EFFECT:="none"}
19 | AUTO_WHITE_BALANCE_MODE=${AUTO_WHITE_BALANCE_MODE:="auto"}
20 | H264_PROFILE=${H264_PROFILE:="high"}
21 |
22 | echo "Starting raspivid..."
23 | raspivid -n -t 0 -w $WIDTH -h $HEIGHT -drc $DRC -sh $SHARPNESS -br $BRIGHTNESS -co $CONTRAST -sa $SATURATION -ifx $IMAGE_EFFECT -g $INTRA_REFRESH_PERIOD $FLIP_HORIZONTAL $FLIP_VERTICAL -rot $ROTATION -fps $FRAMES_PER_SECOND -b $BITRATE -mm $METERING_MODE -ex $EXPOSURE_MODE -ih -pf $H264_PROFILE -awb $AUTO_WHITE_BALANCE_MODE -o udp://$STREAM_DESTINATION_IP:$STREAM_DESTINATION_PORT
24 | echo "Raspivid exited."
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Raspberry Pi UDP Camera
2 |
3 | [](https://twitch.tv/hotsparklab) [](https://streamelements.com/hotsparklab/tip) [](https://foldforcovid.io/)
4 |
5 | Create a **low-latency** (*fast*) video camera with a [Raspberry Pi](https://www.raspberrypi.org/) and [camera module](https://www.raspberrypi.org/products/camera-module-v2/). Stream the video in realtime to a Mac, PC or other Pi for use in media projects in [Open Broadcaster Software (OBS)](https://obsproject.com/) and other media tools. Optionally scale up by creating a fleet of cameras that broadcast video to one or more machines.
6 |
7 | Raspberry Pi UDP Camera is not a webcam, however it may be used similarly via [obs-gstreamer](https://github.com/fzwoch/obs-gstreamer) (for OBS), [GStreamer](https://gstreamer.freedesktop.org/) projects in general and other software (todo for other software, untested, solutions welcome).
8 |
9 | This project was created with a need to use multiple cameras in a [live Twitch stream](https://twitch.tv/hotsparklab). During a pandemic, webcams have been considerably more expensive, while Raspberry Pi camera modules offer arguably higher quality video than some webcams. With Pis and camera modules handy, let's share.
10 |
11 | ## Setup balenaCloud Application
12 |
13 | Using balena.io allows for quick deployment and monitoring of Docker-driven apps to devices such as Raspberry Pi (among others). It also allows for mass deployment, monitoring and updates, which had a use case when this project was created (multiple low-latency cameras for the [HotSparkLab](https://twitch.tv/hotsparklab) Twitch stream).
14 |
15 | ### Quick Setup
16 |
17 | Use the following link to quickly setup the app in balena.io. See *Slow Setup* below for full details of what's included and various options.
18 |
19 | [](https://dashboard.balena-cloud.com/deploy)
20 |
21 | ### Slow Setup
22 |
23 |
24 | Expand
25 |
26 | Here's a full run-through from scratch if not using the deploy button above, including descriptions of available options and where they live.
27 |
28 | ## Configure the Pi Camera Fleet
29 |
30 | Setup a [belana.io account](https://dashboard.balena-cloud.com/signup).
31 |
32 | On the [Applications dashboard](https://dashboard.balena-cloud.com/apps), choose **Create application**.
33 |
34 | The camera fleet of one or more Pis will be configured with defaults that will apply to all potential camera devices. Select **Fleet configuration** on the left navigation.
35 |
36 | Under **CUSTOM CONFIGURATION VARIABLES**, add the following variables and values. Memory will adapt to what's available on the Pi:
37 |
38 | | Variable Name | Value |
39 | | --- | --- |
40 | | BALENA_HOST_CONFIG_start_x | 1 |
41 | | BALENA_HOST_CONFIG_gpu_mem_256 | 192 |
42 | | BALENA_HOST_CONFIG_gpu_mem_512 | 256 |
43 | | BALENA_HOST_CONFIG_gpu_mem_1024 | 448 |
44 |
45 | Select **Environment Variables** in the left menu. Add the following required environment variables and values that tell the camera which computer to broadcast to.
46 |
47 | | Environment Variable | Value | Description |
48 | | --- | --- | --- |
49 | | STREAM_DESTINATION_IP | Example: 192.168.0.10 | This is the local IP address of the computer that will receive the UDP video stream. |
50 | | STREAM_DESTINATION_PORT | Example: 5001 | This is the the port of the receiving computer to send to. Note that this will need to be unique per camera if the computer is receiving multiple video streams. As this is in the fleet environment variables as the default, it can be overridden per device as needed. |
51 |
52 | Additional optional environment variables may be set as needed to customize camera/raspivid settings.
53 |
54 | | Environment Variable | Default Value | Description |
55 | | --- | --- | --- |
56 | | WIDTH | 1280 | Available camera image width as [supported by raspistill](https://www.raspberrypi.org/documentation/raspbian/applications/camera.md) (see 'Version 1.x' and 'Version 2.x' depending on Pi camera version used). Choose an option that pairs with IMAGE_HEIGHT. |
57 | | HEIGHT | 720 | Available camera image height as [supported by raspistill](https://www.raspberrypi.org/documentation/raspbian/applications/camera.md) (see 'Version 1.x' and 'Version 2.x' depending on Pi camera version used). |
58 | | ROTATION | 0 | Supported image rotation values: `0`, `90`, `180` or `270` |
59 | | FLIP_HORIZONTAL | | Flip the image horizontally. If enabling, use a value of `-hf`. |
60 | | FLIP_VERTICAL | | Flip the image vertically. If enabling, use a value of `-vf`. |
61 | | FRAMES_PER_SECOND | 30 | A framerate of `2` to `30` frames per second is supported. |
62 | | INTRA_REFRESH_PERIOD | 60 | This option specifies the number of frames between each I-frame. Larger numbers will reduce the size of the resulting video. Smaller numbers make the stream less error-prone. |
63 | | BITRATE | 2500000 | Bits per second. 2500000 would be 2.5Mbits/s. Setting to high will result in stuttering video (untested in this project so far, 2500000 was smooth with Ethernet connection). |
64 | | METERING_MODE | average | The following metering modes are supported: `average`, `spot`, `backlit` or `matrix`. See -mm details [here](https://www.raspberrypi.org/documentation/raspbian/applications/camera.md) for full details. |
65 | | EXPOSURE_MODE | fixedfps | The following exposure modes are supported: `auto`, `night`, `nightpreview`, `backlight`, `spotlight`, `sports`, `snow`, `beach`, `verylong`, `fixedfps`, `antishake`, `fireworks`. See -ex details [here](https://www.raspberrypi.org/documentation/raspbian/applications/camera.md) for full details. |
66 |
67 | ## Uplaod Application via balena.io CLI
68 |
69 | lone the Raspberry Pi UDP Camera repository.
70 |
71 | ```
72 | git clone https://github.com/hotsparklab/raspberry-pi-udp-camera.git
73 | ```
74 |
75 | Follow [these instructions](https://www.balena.io/docs/reference/balena-cli/) to install the balena.io CLI, used to upload the project locally to the balena.io application.
76 |
77 | Login via the CLI (web authentication option when asked is recommended)
78 |
79 | ```
80 | balena login
81 | ```
82 |
83 | List available projects.
84 |
85 | ```
86 | balena apps
87 | ```
88 |
89 | Take note of the app name that was created for Raspberry Pi UDP Camera and push to the app.
90 |
91 | ```
92 | balena push your-app-name-here
93 | ```
94 |
95 | 🦄 A successful deploy will end with an ascii art unicorn named Charlie.
96 |
97 |
98 |
99 | ## Install Raspberry Pi UDP Camera to the Pi
100 |
101 |
102 | Expand
103 |
104 | In the balena.io dashboard, choose **Devices** in the left navigation.
105 |
106 | Click the **Add Device** button at the top.
107 |
108 | In the modal window, set an Application Name and choose the device type, `Raspberry Pi 3` for example (several Pis supported, tested on Pi 3 and Zero Wireless), then choose **Create new application**. Note: Wireless setup can also be configured here. Wireless connections could result in added latency or dropped frames when viewing the camera depending on the connection.
109 |
110 | After downloading the application for the device, it can be burned to a MicroSD card using [balenaEtcher](https://www.balena.io/etcher/). Ensure the camera is installed properly to the Pi. Insert the card. Plug-in via Ethernet on same switch or use wireless if configured as such. Power the device and wait for a couple minutes. Connection status can be tracked on the Balena.io dashboard.
111 |
112 | ## How Stream Video In Open Broadcaster Software via GStreamer (OBS)
113 |
114 | GStreamer is a robust, open source multimedia framework, in this use case great for the purpose of receiving and displaying video broadcasted from the Pi. The [obs-gstreamer](https://obsproject.com/forum/resources/obs-gstreamer.696/) plugin bridges the gap between GStreamer and OBS, allowing configuration and display within OBS for a new "GStreamer source" (kinda like VLC Player, more robust and without a UI).
115 |
116 |
117 | ## Setup Open Broadcasting Software (OBS) To Use Camera(s)
118 |
119 |
120 | Expand
121 |
122 | ### Install GStreamer (Windows 10)
123 |
124 | For the [obs-gstreamer](https://github.com/fzwoch/obs-gstreamer) to work, GStreamer runtime and the GStreamer development SDK will need to be installed to the PC. Note: There's an experimental Mac and Linux obs-gstreamer plugin, untested here. Post an issue or PR to inform us how it works if you use it.
125 |
126 | Download the **MinGW 64-bit** (or 32-bit if needed) runtime and development installers from [GStreamer's website](https://gstreamer.freedesktop.org/download/) and install.
127 |
128 | ### Add GStreamer to PATH Environment Variable (Windows 10)
129 |
130 | An environment variable will need to be added to Windows PATH so that obs-gstreamer knows where to look for GStreamer. Otherwise, it won't show as an option in OBS.
131 |
132 | Open Control Panel and search for **environment variables** on the top-right.
133 |
134 | Choose **Edit environment variables for your account**.
135 |
136 | Add a new environment variable with **variable name** of `GSTREAMER_1_0_ROOT_X86_64` and **variable value** of `C:\gstreamer\1.0\x86_64` (or wherever you installed GStreamer if different).
137 |
138 | Hit the **OK** button, then the parent window's **OK** button to finish up.
139 |
140 | ## Install obs-gstreamer Plugin to OBS
141 |
142 | obs-gstreamer will enable a new configurable "GStreamer source" in OBS.
143 |
144 | Visit the [obs-gstreamer](https://obsproject.com/forum/resources/obs-gstreamer.696/) page and choose **Go to download**.
145 |
146 | Download and extract the latest **obs-gstreamer.zip**.
147 |
148 | copy **obs-gstreamer.dll** into **C:\Program Files\OBS\plugins** (64-bit) or **C:\Program Files (x86)\OBS\plugins** (32-bit), altered if OBS was installed elsewhere.
149 |
150 | ## Add Streaming Video From Raspberry Pi To OBS
151 |
152 | Now for the fun part. Get live, low-latency video from the Pi to show in OBS as a video source.
153 |
154 | ### Find Streaming Computer IP Address
155 |
156 | The Pi with camera will send video to the streaming computer via UDP. To do that, the Pi will need to know the streaming computer's local IP address.
157 |
158 | In Windows, type `cmd` in the Windows Start search bar and hit enter to launch Windows terminal.
159 |
160 | Type, `ipconfig` and press Enter.
161 |
162 | The IP address will be towards the top and looking similar to, `192.168.0.X (just not the .255 one listed). Note that address.
163 |
164 | ### Point the Pi Fleet To the Streaming PC
165 |
166 | Back to the balena.io for a moment, visit the application's Environment Variables page. Update **STREAM_DESTINATION_IP** value to the noted IP address above.
167 |
168 | If multiple Pis are going to be running the application for the same streaming computer, make sure each device specifies a unique **STREAM_DESTINATION_PORT**, e.g. `5001`, `5002`, etc.
169 |
170 | ### Add a GStreamer Source in OBS
171 |
172 | Launch OBS.
173 |
174 | With a scene active, under **Sources**, choose **+**.
175 |
176 | Select **GStreamer Source**.
177 |
178 | In the pipeline field enter the following, replacing YOUR_PI_PORT with the port specified in belana.io for that device (or fleet port is fine if there's only one device).
179 |
180 | ```
181 | udpsrc port=YOUR_PI_PORT ! h264parse ! avdec_h264 ! video.
182 | ```
183 |
184 | If/when the Pi is booted and running, the camera source will be displayed in the scene and can be scaled and filtered to taste. Note: Pi status can be monitored in the balena.io dashboard with latest logs shown.
185 |
186 | 🚨🎉🚨🎉
187 |
188 |
189 |
190 | ## How To Stream Video To VLC Player
191 |
192 | There hasn't been luck successfully playing this formatted UPD video stream in VLC Player on Mac or PC yet (or any **low-latency** video stream from a Pi to VLC Player). Prove me wrong. Post an issue or PR with the solution. Let's add instructions for it as it would be very accessible to OBS users with VLC Player already installed (if simple and possible).
193 |
194 | ## How To Stream From A Raspberry Pi As A Webcam
195 |
196 | While untested here, UDP video streams have been known to be used as webcams for a receiving computer through third-party applications. A [Google search](https://www.google.com/search?q=use+udp+camera+as+webcam+source&oq=use+udp) brought up several results to explore. Which solution works for you? Post an issue or a PR and share!
197 |
198 | ## Special Thanks
199 |
200 | Many more holes would be in the wall with far fewer brain cells active today if it wasn't for [fzwoch](https://github.com/fzwoch)'s [obs-streamer](https://obsproject.com/forum/resources/obs-gstreamer.696/) project. Also thanks to great comments from [Dregu](https://github.com/Dregu) and [crossan007](https://github.com/crossan007) in [this issue](https://github.com/fzwoch/obs-gstreamer/issues/3) and the [balena.io](https://balena.io) team for their feedback on live streaming topics. Thank you!
201 |
--------------------------------------------------------------------------------