summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-17 20:34:01 -0400
committerCara Salter <cara@devcara.com>2022-06-17 20:34:01 -0400
commit8bd904670f0e7acea40d0f7f34fac0df502a74c1 (patch)
treee15c60e98cd9d5c025b96e064071483d5f81083f
parentce50fbcdd51f47bad3fd85e91c030879ce5dfad8 (diff)
downloadsite-8bd904670f0e7acea40d0f7f34fac0df502a74c1.tar.gz
site-8bd904670f0e7acea40d0f7f34fac0df502a74c1.zip
Custom RTMP server
l---------.direnv/flake-profile1
l---------.direnv/flake-profile-1-link1
-rw-r--r--.envrc2
-rw-r--r--blog/custom-rtmp.md91
-rw-r--r--statics/custom.css8
-rw-r--r--templates/about.rs.html5
-rw-r--r--templates/index.rs.html10
7 files changed, 110 insertions, 8 deletions
diff --git a/.direnv/flake-profile b/.direnv/flake-profile
new file mode 120000
index 0000000..0c05709
--- /dev/null
+++ b/.direnv/flake-profile
@@ -0,0 +1 @@
+flake-profile-1-link \ No newline at end of file
diff --git a/.direnv/flake-profile-1-link b/.direnv/flake-profile-1-link
new file mode 120000
index 0000000..b738dee
--- /dev/null
+++ b/.direnv/flake-profile-1-link
@@ -0,0 +1 @@
+/nix/store/334wfqshf6xiqw1i12rrx3a65pivy4wk-nix-shell-env \ No newline at end of file
diff --git a/.envrc b/.envrc
index 051d09d..3550a30 100644
--- a/.envrc
+++ b/.envrc
@@ -1 +1 @@
-eval "$(lorri direnv)"
+use flake
diff --git a/blog/custom-rtmp.md b/blog/custom-rtmp.md
new file mode 100644
index 0000000..e1a89fb
--- /dev/null
+++ b/blog/custom-rtmp.md
@@ -0,0 +1,91 @@
+---
+title: Self-hosting a Live Stream Server
+author: Cara Salter
+date: 2022-06-15
+---
+
+This Sunday, I will be running the technical side of an online Pride event
+hosted by my partner. Part of this includes live music performances that all
+need to go to the same stream output. I also need to be able to scale and
+transcode the streams appropriately. There are, of course, commercial options
+available, but that wouldn't be very fun (or cheap!). What fun is having servers
+if I can't also mess around with them?
+
+The specific final destination has particular codecs and resolutions, and they
+recommend something like [Oven Media Engine][ome] to take in all the streams and
+allow them to be rebroadcasted into their intake server. I spent most of today
+trying to make it work, and while I was able to successfully *send* to it, I
+couldn't get anything out of it, no matter how much I tried. This was mostly
+because of a lack of understanding on my part, but also the relatively
+confusing-to-newcomers way that the configuration and documentation is
+presented.
+
+That's not to say that it's unfriendly to new users, just that it requires a lot
+more prior knowledge and research than I expected or was capable of dealing with
+in the moment. I'm sure it's a wonderfully useful software, it just didn't
+fulfill my need for something that could be set up and tested for this weekend.
+
+Eventually I remembered an [old post][ddevault] by Drew DeVault that talked
+about self-hosting his own live-streaming server with `nginx`. In it, he streams
+a screengrab of an X11 window via `ffmpeg`[^1] into a DASH[^2] sink using the
+`nginx-rtmp` module.
+
+This looks great! Streaming into nginx that then can be republished and pulled
+into OBS for transcoding and restreaming. I ended up installing the RTMP module
+on one of my servers, and wrote the following configuration:
+
+```
+rtmp {
+ server {
+ listen 1935;
+ chunk_size 4096;
+
+ application live {
+ live on;
+ record off;
+ }
+ }
+}
+```
+
+That's really all it takes. `1935` is used because it's the standard RTMP port,
+but really any one can be used. This lets me send streams to
+`rtmp://<my-server>:1935/live/<key or name>`. Where it says `<key or name>`,
+that's the bit where you can separate each stream. Then, I can add a Media
+Source to OBS or VLC with that same URL, and it will automatically pull the
+stream down. By managing stream keys, you can have multiple people streaming in
+at once, and then switch between them using software like OBS.
+
+I'm mostly using the stock OBS settings, but I'm making sure to use the `x264`
+encoder and the `veryfast` encoder preset, which is easier on web browsers.
+There's no noticable difference in quality, so in my opinion there's no need to
+go any higher.
+
+The RTMP module also lets you use the nginx `allow` and `deny` directives, for
+access control based on IP addresses or subnets. For example, if I only wanted
+to be able to stream from within my VPN, I could set
+
+```
+allow publish <my-laptops-vpn-ip>;
+deny publish all;
+```
+
+which would only let my laptop (or any other IP I wanted) broadcast. I'm sure
+there's some way to do this better, like predetermining which stream keys are
+able to play, but I haven't been able to find it yet, so I've just been
+disabling the module when I don't need it.
+
+To recap, the general steps I took were:
+1. Install and configure the nginx RTMP module
+2. Configure OBS to stream to the RTMP URL
+3. Add a media source to VLC with that same URL to play
+
+I hope this was able to help! I plan on looking into this more, especially the
+access control bits, so I'll be sure to update this post with anything I find.
+
+[^1]: Which, if you didn't know, is a really wonderful tool that can do
+basically anything related to A/V including transcoding and streaming.
+[^2]: Dynamic Adaptive Streaming over HTTP
+
+[ome]: https://ovenmediaengine.com
+[ddevault]: https://drewdevault.com/2018/08/26/Self-hosted-livestreaming.html
diff --git a/statics/custom.css b/statics/custom.css
index d13f117..03a8f72 100644
--- a/statics/custom.css
+++ b/statics/custom.css
@@ -10,7 +10,11 @@ a {
/* Base container */
.container {
margin: auto; /* centered */
- width: 80%; /* looks nice */
+ width: 60%; /* looks nice */
+}
+
+.centered {
+ margin: auto;
}
/* Navbar */
@@ -43,6 +47,8 @@ a {
.inner-column {
flex: 50%;
+ margin-right: 0.5rem;
+ margin-left: 0.1rem;
}
/* Post list */
diff --git a/templates/about.rs.html b/templates/about.rs.html
index 95fb994..010a5ab 100644
--- a/templates/about.rs.html
+++ b/templates/about.rs.html
@@ -40,4 +40,9 @@
</div>
</div>
+<div class="centered">
+ <h3>solard</h3>
+ <p>REST API management plane for virtual machines, to enable remote
+ management across a network.</p>
+
@:footer_html()
diff --git a/templates/index.rs.html b/templates/index.rs.html
index 0b8ddc0..fc3ea8c 100644
--- a/templates/index.rs.html
+++ b/templates/index.rs.html
@@ -13,7 +13,7 @@
<h3>About me</h3>
I am a:
<ul>
- <li>Trans <div class="p-gender-identity">woman</div> (she/her)</li>
+ <li>Trans woman (she/her)</li>
<li>Eagle Scout</li>
<li>Software Engineer</li>
</ul>
@@ -32,6 +32,7 @@
My past projects are, in no particular order:
<ul>
+ <li><a href="https://git.carathe.dev/solard">solard</a></li>
<li><a href="https://sr.ht/~muirrum/wg-manager">WG-manager</li>
<li><a
href="https://sr.ht/~muirrum/Campmaster-Constantine">Campmaster
@@ -47,15 +48,12 @@
<h3>Skills</h3>
<h4>Web Development</h4>
<ul>
- <li>Rust (Warp)</li>
- <li>Go (Gin-gonic)</li>
+ <li>Rust (Axum)</li>
<li>Python (Django/Flask)</li>
- <li>NodeJS (Svelte)</li>
</ul>
<h4>Systems Administration</h4>
<ul>
- <li>Prometheus & Zabbix Monitoring/Alerts</li>
- <li>Ansible</li>
+ <li>Prometheus Monitoring/Alerts</li>
<li>Shell scripting</li>
<li>Nginx</li>
<li>Wireguard</li>