Hi,

2018-07-27 14:47 GMT-05:00 Bruno Lima <bruno.npl@...>:

Hi, I described my problem in more details here:

https://github.com/savonet/liquidsoap/issues/584


I have a jackd input on liquidsoap and mp3 and opus outputs. I need to
get the metadata from a MySQL table and update it on the output stream
every 10 seconds.


The metadata is Title and Artist.


I have already checked the page describing metadata mechanisms as
suggested but couldn't see how I can implement that as I am not very
experienced with this.


If anyone could give me an example of how I could do it would be great!

Since jack inputs do not have metadata or track marks, you will need to
insert those yourself at the required time.

In this page: http://www.liquidsoap.info/doc-1.3.3/metadata.html you will
find a detailed example that should guide you through the process.
Basically, you need to do the following:

* Use insert_metadata to obtain a way to programmatically insert new
metadata. This is described in the example
* Use add_timeout to run a function every 10 seconds
* Write the function to insert metadata that will be executed each 10
seconds. This part you almost already have it.

Additionally you may want to use a variable reference to keep track of the
last inserted metadata and only update if it has changed.

Hope this helps!
Romain


Hello, I tried a code based on the Radio Nova example with no success 
(http://www.liquidsoap.info/doc-1.0.1/radio-nova.html)

#!/usr/bin/liquidsoap
set("log.file.path","liquidsoap.log")
set("frame.audio.samplerate",48000)

radio = input.jack()

# add a hook to insert new metadata
radio = insert_metadata(radio)

# This string references will be used to keep track
# of previous metadata
title = ref "unknown title"
artist = ref "unknown artist"


# Process that grabs and inserts metadata on stream
def add_meta()
log = log(level=4)
log("Checking for metas")
new_artist = list.hd(
get_process_lines(
"sudo mysql playlist -u root -pc0d3c8000 -se \"SELECT CAST(CONVERT(Artist USING utf8) AS 
binary) FROM musica_atual WHERE id='1'\""
)
)
new_title = list.hd(
get_process_lines(
"sudo mysql playlist -u root -pc0d3c8000 -se \"SELECT CAST(CONVERT(Title USING utf8) AS 
binary) FROM musica_atual WHERE id='1'\""
)
)
old_title = !title
old_artist = !artist
if (old_title != new_title or old_title != new_title) and
(new_title != "" or new_artist != "")
then
log("Got new metas: #{new_artist} -- #{new_title}")
ignore(
server.execute(
'radio.insert artist="#{new_artist}",title="#{new_title}"'))
title := new_title
artist := new_artist
else
log("Keeping old metas")
end
5.0
end

# Schedule the insert process every 5.0 second
add_timeout(fast=false,5.0,add_meta)

output.icecast(%vorbis ,
host="localhost",
port=8000,
password="c0d3c8000",
mount="radiotest.ogg",
url="http://localhost:8000";,
radio
)

Any ideas on what I am doing wrong?

Thanks!
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to