-
I am downloading two mp3 streams via http. I want to determine their samplerate and/or bitrate so I can stream that back out at the same encoding. (No reason to transcode up.) Does the Liquidsoap API allow me to obtain this info from the input streams? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi! If your intent is to restream without transcoding, the way to do it is via the raw ffmpeg format. Something like this: s = input.http("http://...")
# You need to know at least the format:
encoder = %ffmpeg(format="mp3", %audio.raw)
# Restream without re-encoding:
output.icecast(
mount="...",
...,
fallible=true,
encoder,
s
) Here's a full example with a switch between two sources: s1 = input.http("https://supersoul.live:8020/SRRS320kbps")
s2 = input.http("https://supersoul.live:8020/SRRS128kbps")
b = blank()
b = ffmpeg.encode.audio(
%ffmpeg(%audio(codec="libmp3lame", b="128k")),
b
)
s = switch(id="switch", track_sensitive=false, [
({file.exists("/tmp/s1")},s1),
({file.exists("/tmp/s2")},s2),
({true},b)
])
e = %ffmpeg(format="mp3", %audio.copy)
output.harbor(id="harbor", mount="test", e, s) You can switch between the two sources by creating/removing files at Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Cool thank you! I'm actually combining two sources via pan and add, and streaming them out, so I do need to re-encode. I was hoping to query the samplerate of the input sources to determine output samplerate. Is that possible? |
Beta Was this translation helpful? Give feedback.
-
Ha. Well, in this case, the data is converted to the internal format's samplerate, set via:
You will have to have all your incoming streams with the same samplerate if you want to avoid resampling. As a rule of thumb, I would consider the trouble/benefit about tweaking this pretty minor in terms of CPU load and/or audio quality. However, if you really want to try to be conservative, you can set the internal samplerate to a the higest common value, for instance There are also specific settings that you can use with the |
Beta Was this translation helpful? Give feedback.
Ha. Well, in this case, the data is converted to the internal format's samplerate, set via:
You will have to have all your incoming streams with the same samplerate if you want to avoid resampling.
As a rule of thumb, I would consider the trouble/benefit about tweaking this pretty minor in terms of CPU load and/or audio quality. However, if you really want to try to be conservative, you can set the internal samplerate to a the higest common value, for instance
48000
and trust conversion to preserve most information.There are also specific settings that you can use with the
libsamplerate
based converter, some of which will give you higher quality resampling. H…