Comments (2)
As it is currently built, this is not possible. Many changes would have to be made to the video pipeline to have something like that work. If you're looking for something that legitimately only streams audio, I recommend Icecast, as that is built for that purpose.
from owncast.
Not sure if this is gonna help you, but maybe other people want the same thing, so in the hopes that this is useful to you or someone in the future, I'll post this here:
My workaround to this was setting up an nginx server, with the nginx-rtmp-module, ffmpeg
and Caddy to serve an audio only stream.
The command below feeds off the original stream, strips the video, then pipes the audio to nginx:
ffmpeg -i http://video.mydomain.tv/hls/stream.m3u8 -c:a copy -vn -f flv rtmp://localhost:1935/live/
Here's the nginx config:
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
# nginx default
events {
worker_connections 768;
}
rtmp {
server {
listen 1935; # RTMP port
chunk_size 4096;
application live {
live on;
record off; # only creates ephemeral files, old chunks will be deleted right away
hls on;
hls_path /var/www/html/stream/hls; # create this dir and make sure it's writable
hls_fragment 5s;
hls_playlist_length 30s;
}
}
}
http {
server {
listen 9090;
location /hls {
root /var/www/html/stream;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *; # or restrict this to only be accessible from your website
}
}
# rest of your config, if any
}
You can then configure nginx to expose it to the web, which is a bit complicated, especially with SSL, or simply set up a Caddy server in front of it, which is what I did. Assuming you'll already have your audio domain set up as audio.mydomain.tv somewhere (e.g Cloudflare)
Caddyfile (usually under /etc/caddy/Caddyfile):
audio.mydomain.tv {
reverse_proxy /hls/* localhost:9090 # nginx server
encode gzip
tls [email protected]
}
Ideally, you'll have some mechanism in place to start the audio stream the moment its related Owncast stream starts.
This can be done by combining Owncast's webhook feature and a middleware service capable of performing HTTP requests. Below is how I've done it:
Copy the ffmpeg
command in a start_stream.sh
script and set up a Caddy endpoint with the exec plugin so you can programmatically start a stream.
Updated Caddyfile with a /start
endpoint:
audio.mydomain.tv {
reverse_proxy /hls/* localhost:9090
encode gzip
tls [email protected]
@not-options not method OPTIONS # so your server doesn't get 401'd, don't ask me why this happens
route /start {
basicauth {
user {ecrypted-password} # read more https://caddyserver.com/docs/caddyfile/directives/basicauth
}
exec {
command /path/to/start_stream.sh
timeout 10s
}
}
}
Now using Owncast's webhook feature, you'll be able to start the audio stream from a middleware service. In my case, we already have a nodejs server up and running. It made sense to just add another endpoint for this purpose.
Here's the nodejs snippet, using express.js
and axios
to perform HTTPS requests:
//LiveStreamController.js
const startAudioStream = async (request, response) => {
// incoming Owncast webhook notification
const payload = request.body;
try {
const type = payload.type;
const { CADDY_SECRET } = process.env; //already generated secret from btoa(`${user}:${password}`)
const headers = {
'Authorization': `Basic ${CADDY_SECRET}`,
"Content-Type": "application/json",
};
if (type === "STREAM_STARTED") {
await delay(5000) // Wait 5 seconds. Can't start audio stream right away, gotta wait for a bit
await axios.get("https://audio.mydomain.tv/start", {
headers,
});
}
} catch (error) {
return response.status(500).json({ message: "Something happened" });
}
return response.status(200).json({ message: "Success" });
};
Now when the stream starts, Owncast will fire a START_STREAM notification to your webhook, and it'll be able to start an audio stream in your ffmpeg/nginx/caddy server.
If you don't have a server ready to use as middleware for any reason and don't want to set up one, you can get away with simply having a curl
command ready, or even a Postman or Insomnia request to start the audio stream right after starting your original stream.
You don't need to set up a STOP_STREAM notification, because once the original stream stops and the feed dies, ffmpeg
will stop automatically a few moments later.
With this set up, your audio stream will be available at https://audio.mydomain.tv/hls/stream.m3u8.
from owncast.
Related Issues (20)
- Support remote lookups of webfinger accounts and autolink them in outbound Fediverse posts HOT 1
- Any stream I watch buffers every 5 seconds HOT 3
- aria live: user name remains logged in name
- aria live: html entities are not decoded
- New offline embed state not handling HTML HOT 4
- New offline embed has overflow problems HOT 3
- [Feature] Add 2FA to Admin Authentication HOT 1
- Update project to Go 1.22
- Auth related integration tests are flaky and needs to be looked into why they're failing HOT 1
- Total number of viewers -ever (feature request) HOT 5
- Remove usage of utils/restendpointhelper.go in favor of the new router HOT 4
- Allow image upload in chat HOT 4
- Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub HOT 3
- [Feature Request] External Chat Filter HOT 1
- Live streams that are between 24 and 25 hours display the time as "Live for 1 day undefined hours" HOT 2
- Write documentation around the OpenAPI spec-based API layer
- Validate and troubleshoot any issues dealing with the pagination middleware after the router change
- Documentation broken link: https://www.kiloview.com/en/encoder/h264-wired/ HOT 2
- Migrate suite of automated browser tests to our new LambdaTest account HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from owncast.