Closed xogium closed 1 year ago
Hi @xogium,
I need to ask a few questions so I can try to reproduce your problem
It is a standard stream from obs, mpegts format, content_type=video/m2ts. The audio is mp2 and the video codec is mpeg2video.
Looks not very standard. Is it necessary to stream in mpeg2
to icecast?
Why wouldn't you use input.rtmp
or input.srt
?
Hi! I run liquidsoap installed via opam on archlinux. I currently run the very latest code in the main branch.
As for why I did icecast, well. I initially streamed directly to icecast using this technic. I noticed a few problems with it, such as the fact that you can't use multiple words when defining stream name and genre, no matter if you quote them or not. Another advantages of using ls is that I can mix in audio of the stream with a playlist in the background eventually -- obs is on windows, ls is on linux.
As for why no rtmp/srt, I simply have no clue how these works, nor how to configure them in obs.
Hope this helps!
One thing I forgot to mention is that I am unsure what format to use other than this. I've tried webm but it keeps crashing obs unfortunately, so I stick with the format that wors, which just so happened to be mpegts.
As for why no rtmp/srt, I simply have no clue how these works, nor how to configure them in obs.
To stream from OBS you should configure custom server in the stream settings. And use the streaming tab in the output settings.
The liquidsoap live
could be configured like this
live = input.rtmp('rtmp://0.0.0.0:8000/a/b')
installed via opam on archlinux
Also available in aur.
Hi, unfortunately the screenshots you've sent are not useful to me since I'm blind. Can you explain in text please?
As for the aur package, I've tried to use that, but I've had too many issues with it and stick to opam these days. I kept having problems to compile this or that, and it was just too much mess to maintain. Opam is much easier. But thanks for pointing it out!
Can you explain in text please?
Sure.
rtmp://YOUR_SERVER_ADDRESS:PORT/ENDPOINT
.
Replace YOUR_SERVER_ADDRESS
with the correct address of your server.
Replace PORT
with the port of the server, for example 8000
.
Replace ENDPOINT
with the path to the application, for example, app
.YOUR_SECRET_KEY
, for example, b
.To configure the liquidsoap you can use input.rtmp
.
This function accepts string in format "rtmp://IP_ADDRESS:PORT/ENDPOINT/YOUR_SECRET_KEY"
IP_ADDRESS
with 0.0.0.0
.PORT
with any port, for example 8000
. Use the same port as in the OBS config.ENDPOINT
with the path to the application, for example, app
. Use the same path as in the OBS config.YOUR_SECRET_KEY
with the key, for example, b
. Use the same path as in the OBS config.You can store encoder settings in the variable.
enc = %ffmpeg(%audio.copy, %video.copy, format="mpegts")
Here's the resulting liquidsoap script
live = input.rtmp("rtmp://0.0.0.0:8000/app/b")
enc = %ffmpeg(%audio.copy, %video.copy, format="mpegts")
output.icecast(
enc,
live,
transport = http.transport.tls(),
host = "radio.domain.tld",
port = 8443,
mount = "/vstream.ts",
password = "password",
)
But there's a catch ffmpeg has not implemented strict verification for endpoint and key. The patch was discussed but hasn't been merged.
The other possibility is to use SRT. OBS has a guide about SRT streaming. The header of the section is Stream with SRT. To stream using SRT you should change the settings.
srt://YOUR_SERVER_ADDRESS:PORT?passphrase=YOUR_PASSPHRASE
.
Replace YOUR_PASSPHRASE
with a random passphrase with a length from 10 to 79 symbols.In the liquidsoap config use the input.srt
function instead of input.rtmp
.
The input.srt
function has a lot of options.
The most useful are
bind_address="IP_ADDRESS"
- the server listen address, the same as in rtmp.
The default value is 0.0.0.0
.port=PORT
- the port of the srt server, similar to rtmp.
The default value is 8000
.passphrase="YOUR_PASSPHRASE"
- the secret password required to connect to the stream.
Use the same value as in the OBS settings.enforced_encryption=true
- used in combination with the passphrase to ensure authentication and authorization.The liquidsoap with the SRT will look like
live = input.srt(
bind_address="0.0.0.0",
port=8000,
passphrase="YOUR_PASSPHASE",
enforced_encryption=true,
)
enc = %ffmpeg(%audio.copy, %video.copy, format="mpegts")
output.icecast(
enc,
live,
transport = http.transport.tls(),
host = "radio.domain.tld",
port = 8443,
mount = "/vstream.ts",
password = "password",
)
Thank you so much! This works as I need now.
Fwiw, I chose srt, seemed the less annoying of them to set up.
I'm still curious why the mpegts stream didn't want to get through ffmpeg, that said. Any ideas on that one?
I'm still curious why the mpegts stream didn't want to get through ffmpeg, that said. Any ideas on that one?
You can enable option Show all codecs, like it's done in the ePirat's blog post.
This option will enable you to choose libx264 as the video encoder and aac as the audio encoder.
But there was an error. The configured value for Muxer Settings is content_type=video/mp2ts
. This is the incorrect mime type for mpegts. It should be video/mp2t, not video/mp2ts. It's also possible to leave this field empty.
icecast://source:hackme@127.0.0.1:8000/example.ts
.By the way, I have found another type of error. It's not possible to set another encoder without restarting the liquidsoap when copy-codec is used.
Hi all! This great and helpful. For future reference, decoder mime types for ffmpeg
(and others) can be set at runtime using settings.decoder.mime_types.ffmpeg
: doc here
input.harbor
wouldn't seem like the most suited input for OBS indeed. The two typical method with it are rtmp
or srt
.
Thanks for all the details. I'm converting this to a discussion so it can stick around.
I'm trying to use the following script in order to grab the audio and video from obs and pass it to liquidsoap. Since obs is already encoding, I'm attempting to use the audio and video copy of ffmpeg in order to avoid encoding again.
The problem comes from the input itself. Liquidsoap seems unable to find a decoder to handle the stream. It is a standard stream from obs, mpegts format, content_type=video/m2ts. The audio is mp2 and the video codec is mpeg2video. Nothing that ffmpeg should have trouble decoding, I imagine.
The error I get is
2023/09/23 16:41:37 [decoder:3] Unable to find a decoder for stream mime-type "video/m2ts" with expected content {audio=ffmpeg.copy,video=ffmpeg.copy}!
What am I missing/doing wrong?