AzuraCast / AzuraCast

A self-hosted web radio management suite, including turnkey installer tools for the full radio software stack and a modern, easy-to-use web app to manage your stations.
https://www.azuracast.com/
GNU Affero General Public License v3.0
3.1k stars 569 forks source link

Related to #1115 How to cast via ffmpeg #1706

Closed m-anish closed 5 years ago

m-anish commented 5 years ago

Hi, @TildeSlashC0re @SlvrEagle23

Apropos to #1115, on the server (Internet-in-a-Box) that I'm trying to setup, I am able to stream via ffmpeg to Azuracast with the following commands

Playing from the file (note the -re switch, otherwise it won't work):

ffmpeg -re -i $music_file_on_disk -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 icecast://user:password@<azuracast-ip>:<port>/<mountpoint>

Playing from a source (like a mic):

ffmpeg -f alsa -i hw:1 -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 icecast://user:password@<azuracast-ip>:<port>/<mountpoint>

In both cases the stream works! However, I don't see the information on the playing bar updated. Do you think there is a way via ffmpeg, where I can get the info on the public player page to update as well?

m-anish commented 5 years ago

It seems that ffmpeg provides options like ice_name, ice_description, but I can't seem to get it to work. Anybody else have luck with it?

Another option might be some liquidsoap config directives? Something like: If this streamer is streaming, then set the title to that.

m-anish commented 5 years ago

My IIAB PR now has support to auto-live-stream the audio segment of a hls stream to Azuracast https://github.com/m-anish/iiab/blob/videostream/roles/cham/templates/nginx.conf.vaapi.j2#L68

So it would be helpful to have this, or some other way (through some other command) to set basic stream info - like "Live stream" if nothing else :-)

m-anish commented 5 years ago

Any update/tips/ideas? :)

m-anish commented 5 years ago

For what it's worth, if I look at the debug output from ffmpeg, I see this information:

This is when the command line looks like:

ffmpeg -v debug -re -i 'file.mp3' -c:a libvorbis -b:a 96K -ice_public 1 -content_type audio/ogg -ice_name "my great stream" -ice_description "this is a great stream" -f ogg icecast://eka1:eka1@192.168.1.103:8005/live

[http @ 0x561c4b1ce8c0] request: PUT /live HTTP/1.1
User-Agent: Lavf/57.83.100
Accept: */*
Expect: 100-continue
Connection: close
Host: localhost:8005
Content-Type: audio/ogg
Icy-MetaData: 1
Ice-Name: my great stream
Ice-Description: this is a great stream
Ice-Public: 1
Authorization: Basic ZWthMTpla2Ex

Hope this helps!

m-anish commented 5 years ago

And I see these messages in the Error log

And I see these messages in the Icecast Error log (not sure if this is related)


[2019-07-04  10:52:23] WARN source/source_set_intro Cannot open intro for /mp3-192kbps "/usr/local/share/icecast/web//mp3-192kbps": No such file or directory
[2019-07-04  10:52:23] WARN source/source_set_intro Cannot open intro for /ogg-192kbps "/usr/local/share/icecast/web//ogg-192kbps": No such file or directory
[2019-07-04  10:52:23] WARN source/source_set_intro Cannot open intro for /mp3-64kbps "/usr/local/share/icecast/web//mp3-64kbps": No such file or directory
[2019-07-04  10:52:24] WARN source/source_set_intro Cannot open intro for /radio.ogg "/usr/local/share/icecast/web//radio.ogg": No such file or directory
m-anish commented 5 years ago

And this is the liquidsoap log. Looks as if the metadata is making it till here, and then something happens...

I now suspect a bug @SlvrEagle23

2019/07/04 19:02:52 [lang:3] DJ Source connected! [("User-Agent","Lavf/57.83.100"), ("Accept","*/*"), ("Expect","100-continue"), ("Connection","close"), ("Host","localhost:8005"), ("Content-Type","audio/ogg"), ("Icy-MetaData","1"), ("Ice-Name","my great stream"), ("Ice-Description","this is a great stream"), ("Ice-Public","1"), ("Authorization","Basic ZWthMTpla2Ex")]
2019/07/04 19:02:52 [eka_live_switch:3] Switch to eka_live_fallback with transition.
2019/07/04 19:02:52 [lang:3] AzuraCast Live Connected Response: received
2019/07/04 19:02:52 [threads:3] Created thread "harbor source feeding" (2 total).
2019/07/04 19:02:52 [eka_input_streamer:3] Decoding...
2019/07/04 19:02:52 [eka_live_fallback:3] Switch to blank_6493.
2019/07/04 19:02:58 [eka_live_fallback:3] Switch to audio_to_stereo_6490 with transition.
Vaalyn commented 5 years ago
("Ice-Name","my great stream"), ("Ice-Description","this is a great stream")

I think it should be Icy not Ice

m-anish commented 5 years ago

so this is probably a bug in ffmpeg?

m-anish commented 5 years ago

for what it's worth, when I use butt, the log is this.

2019/07/05 17:25:39 [lang:3] DJ Source connected! [("Authorization","Basic ZWthMTpla2Ex"), ("Host","localhost:8005"), ("User-Agent","butt 0.1.18"), ("Content-Type","audio/mpeg"), ("ice-name","test info"), ("ice-public","1"), ("ice-url"," "), ("ice-genre"," "), ("ice-description","test description"), ("ice-audio-info","ice-bitrate=128;ice-channels=2;ice-samplerate=44100")]

Also, I can custom send headers from ffmpeg https://www.jokecamp.com/blog/passing-http-headers-to-ffmpeg/

Need to know the right ones if I do :)

Vaalyn commented 5 years ago

Take a look at the command line you posted:

ffmpeg -v debug -re -i 'file.mp3' -c:a libvorbis -b:a 96K -ice_public 1 -content_type audio/ogg -ice_name "my great stream" -ice_description "this is a great stream" -f ogg icecast://eka1:eka1@192.168.1.103:8005/live

More specific:

-ice_public 1 ... -ice_name "my great stream" -ice_description "this is a great stream"

If I don't misunderstand how the metadata protocol works I'd try changing it to icy.

m-anish commented 5 years ago

@Vaalyn I'll try that.. meanwhile when I broadcast something from mixxx.

2019/07/05 19:41:10 [lang:3] DJ Source connected! [("Authorization","Basic ZWthOmVrYQ=="), ("Host","box.lan:10005"), ("User-Agent","libshout/2.4.1"), ("Content-Type","audio/mpeg"), ("ice-public","0"), ("ice-name"," "), ("ice-description","This stream is online for testing purposes!"), ("ice-genre","Live Mix"), ("ice-url","https://www.mixxx.org"), ("ice-irc"," "), ("ice-aim"," "), ("ice-icq"," "), ("ice-audio-info","bitrate=128")]
2019/07/05 19:41:10 [zanskar_one_live_switch:3] Switch to zanskar_one_live_fallback with transition.
2019/07/05 19:41:10 [lang:3] AzuraCast Live Connected Response: received
2019/07/05 19:41:10 [threads:3] Created thread "harbor source feeding" (2 total).
2019/07/05 19:41:10 [zanskar_one_input_streamer:3] Decoding...
2019/07/05 19:41:10 [zanskar_one_live_fallback:3] Switch to blank_6453.
2019/07/05 19:41:16 [zanskar_one_live_fallback:3] Switch to audio_to_stereo_6450 with transition.
2019/07/05 19:41:49 [lang:3] Authenticating DJ: eka
2019/07/05 19:41:49 [lang:3] AzuraCast DJ Auth Response: true
2019/07/05 19:41:49 [zanskar_one_input_streamer:3] New metadata chunk ? -- Anish - Live stream!.

Pay special attention to the very last line. "Anish - Live stream!" This is what gets displayed. I wonder which part of the metadata this comes from. I'll look into this. I tried sending mp3 metadata like -metadata title="Anish" -metadata artist="artist" but while ffmpeg reported that it send those tags, it wasn't displayed in the azuracast window

m-anish commented 5 years ago

If I don't misunderstand how the metadata protocol works I'd try changing it to icy.

That didn't work. Those aren't valid switches. "-icy_name" et. al.

m-anish commented 5 years ago

It seems that many softwares (Azuracast included) respect a tag called "StreamTitle". It is usually in the format "Artist - Song" separated by a dash.

If I go to the icecast admin console update the metadata there as "Artist - Song", Azuracast updates it.

m-anish commented 5 years ago

For what it's worth, I figured out how to do this out of band which seems to be the way many people prefer. For reference this is the call that needs to be made:

curl --user <username>:<password> "http://<url:port>/admin/metadata?mount=<mountpoint>&mode=updinfo&song=<artist>+-+<song>"

This is workable for now, so I'll close this issue. Thanks for your support @Vaalyn and @SlvrEagle23

m-anish commented 5 years ago

A slightly prettier way to do this with proper url encoding is the command below

curl -v --user <user>:<password> --data-urlencode mount="/<mountpoint>" --data-urlencode mode="updinfo" --data-urlencode song="Artist - Song" -G "http://<ip/hostname>:<port>/admin/metadata"
7miguelsilva7 commented 5 years ago

Hi, @TildeSlashC0re @SlvrEagle23

Apropos to #1115, on the server (Internet-in-a-Box) that I'm trying to setup, I am able to stream via ffmpeg to Azuracast with the following commands

Playing from the file (note the -re switch, otherwise it won't work):

ffmpeg -re -i $music_file_on_disk -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 icecast://user:password@<azuracast-ip>:<port>/<mountpoint>

Playing from a source (like a mic):

ffmpeg -f alsa -i hw:1 -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 icecast://user:password@<azuracast-ip>:<port>/<mountpoint>

In both cases the stream works! However, I don't see the information on the playing bar updated. Do you think there is a way via ffmpeg, where I can get the info on the public player page to update as well?

Is it possible using a youtube video like a source?