DJ Source buffers and delays for a default stream
  • Hi Everyone,

    First up, Airtime is proving quite useful to us, so thanks to the devs and all the open source people doing so many great things!

    Now, I've looked and read and looked some more and either I just don't understand, or I've not looked at the right bits yet!

    Current setup...

    Airtime 2.5 on Debian squeeze - VPS.
    We have created a single 24h show that repeats forever in the calender, with many DJs selected in the "Who" section and using Airtime Authentication.
    DJ's connect using m3w encoder with the HTTP option using their Airtime username and password. (other encoders don't have HTTP :( )
    DJ's can jump on any time to fill a space and play on longer if the next DJ fails to show up etc. We have given DJs access to icecast to update the meta data for our mount when they go live. "DJ super whoever LIVE" etc.

    Great so far!

    So, we needed a way to ensure there was never any dead air, and that we would never drop listeners etc.
    http://wiki.sourcefabric.org/display/CC/Playing+Random+Songs+on+Silence

    Works great, but if a DJ has a network slowdown, it fades back into the default playlist and then back into the DJ again (we have a 5 sec fade). On some DJs during our testing it's happened quite a lot!

    This isn't good as it also resets the meta data back to what ever file it's playing in the background.

    So... The questions!

    • Can we somehow increase the server buffer, e.g. the audio that is sent by the DJ, so if the DJ has a bit of a network slow down or drops out for say 10 seconds, the server will eat some of its(, say 45 second) buffer until it's empty?
    • If the above isn't possible can we stop the default play list from continuously playing behind the scenes until the source connection from the DJ cuts out, then have it play from the start of a file after a 5-10 second delay?
    • Failing all that, is there something silly I'm missing or am I just "doing it wrong"?!

    We don't want to connect DJs to an Icecast server and insert a scheduled web stream as this would make it too complicated for someone to just keep playing should the next DJ be delayed.

    I have a feeling that part of the answer I seek in in this post http://forum.sourcefabric.org/discussion/16137/autodjbackupfallback-script-needs-finishing-touches-help/p1 and this one http://forum.sourcefabric.org/discussion/16423/solution-for-multiple-djs-and-other-input-streams-why-buffering-may-not-be-the-answer/p1 but I just can't see it.

    Any help or pointers would be greatly appreciated!

    Cheers

    ;)
    Post edited by Jamie at 2014-04-25 09:28:58
  • 13 Comments sorted by
  • In My post here http://forum.sourcefabric.org/discussion/16423/solution-for-multiple-djs-and-other-input-streams-why-buffering-may-not-be-the-answer/p1

    I try to explain that when it comes to drop networks or bad webstreams you are almost helpless to prevent this and therefore you have to develop strategy to deal with it.

    Based on my reading in the manual,one such strategy is to use the stream handover.

    Whilst not stated in that post,If you have a mod ls-script then your leverage can be a slightly better in these options

    • set jingles and others in your  default fallback
    • set  a transition which will include jingles so that before your music start playback,it will play these jingles
    • harbor your dj's through your script where you can set transition and silence for live

    Your statement proves that your system works OK and just for you to develop whatever strategy best suite.

    If you connect to some terrestrial stations,once the feed is dropped ,then there silence solution chips in

    If its automated ,the Dj has to wait until the system checks back to see if the live is connected again.

    If its not the switcher or controller room has to connect back the DJ. on line

    This brings me thinking,,you may need to get silence detection between you Live and Output.

    Google silence detection and try that software


    Good Luck

    VOISSES

     

    Post edited by Voisses Tech at 2014-04-29 09:05:11
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Vote Up0Vote Down hoerichhoerich
    Posts: 627Member, Airtime Moderator
    long speech small sense...
    open ls_script.liq and watch out for "buffer:float" and/or "max:float"
    I did not try to change any of these, but savonet is your friend
    http://savonet.sourceforge.net/doc-svn/reference.html#input_harbor
    I am not sure about more possibilities...

    cheers
    Official Airtime Forum Manager
    --------------------------
    Most of the time an issue is located between keyboard and chair.
  • Great, thank you both for those pointers. I will go and do some more reading and testing and hopefully find a solution. I'll post back one way or another.

    Cheers! :) o7
  • Hello again.

    @Voisses Tech - This is the bit I don't think I'm understanding, "yet"!

    "Harbour your DJs through your script where you can set transition and silence for live"

    I'm guessing it's here.

        switch(id="show_schedule_noise_switch",
                track_sensitive=false,
                transitions=[transition, transition],
                [({!live_dj_enabled}, dj_live), ({true}, s)]

    But I don't know what to change! More reading for me! :/


    @hoerich

    I added this line buffer=45., like below.
    harbor
    your dj's through your script where you can set transition and silence
    for live - See more at:
    http://forum.sourcefabric.org/discussion/16586/dj-source-buffers-and-delays-for-a-default-stream/p1#sthash.EDrDyRSa.dpuf

                input.harbor(id="live_dj_harbor",
                    dj_live_stream_mp,
                    port=dj_live_stream_port,
                    auth=check_dj_client,
                    buffer=45.,
                    max=60.,
                    on_connect=live_dj_connect,
                    on_disconnect=live_dj_disconnect))

    No change, so I had a bit more of a read and changed this value in

    /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_lib.liq

      source = audio_to_stereo(input.http(buffer=5.,max=15.,id=id,autostart=false,initial_url))

    to,

      source = audio_to_stereo(input.http(buffer=45.,max=60.,id=id,autostart=false,initial_url))

    No change.

    So then I tried changing this,

      # We use a custom switching predicate to trigger switching (and thus,
      # transitions) before the end of a track (rather, end of HTTP stream).
      # It is complexified because we don't want to trigger switching when
      # HTTP disconnects for just an instant, when changing URL: for that
      # we use gracetime below.

      def gracetime(~delay=3.,f)

    to,

      def gracetime(~delay=45.,f)

    no change. I haven't changed all at the same time and tested that though.

    I'm sure there are more lovely people willing to help! Cheers ;)
    Post edited by Jamie at 2014-04-29 02:37:54
  • If you read my stupidness in my post ,you will see that you are mixing up

    Cache,Buffers and burst and that all those settings will have no effects.
    Just assume that the writer of the script took 99% care,anything else you fine should be a bug or error.

    You will then come back to my approach

    • set jingles and others in your  default fallback
    •  set  a transition which will include jingles so that before your music start playback,it will play these jingles
    • harbor your dj's through your script where you can set transition and silence for live

    When you have reached that level we can talk.

    I do not recommend any radically settings  changes to existing ls-script,only additions to have it work for you.

    Some of the changes to ls_script suggested in some posts are unnecessary and can only create more trouble for you if airtime makes radical changes

    This is why I explained in this post

    http://forum.sourcefabric.org/discussion/16091/fallover-101-how-to-make-all-scripts-worked-revisted-pt2-advance-reduce-effects-of-upgrade-brok/p1

    What most people do not realise,The Autodj/fallback I wrote on can literally be taken outside airtime and work,should your system goes down.

    I only give you the basic,I want you to expand,so come on my side.it works.

    I do not beat any bush (if I smoke I would puff again),I tried my best to test,then I tell you what will not work.

    If you want your radio to work,I will tell you how.If you are experimenting then I await the results

    Thank you

    Good Luck

    Voisses









    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Vote Up0Vote Down JamieJamie
    Posts: 6Member
    Hello, me again!

    Right, I have done some more reading, and have use of another server just for testing!

    I love the tap analogy by the way!

    Right, so, I don't think I have explained myself as well as I could!

    I have made a picture... (in MS Paint! :) )

    image
    All the audio makes it to the server, but some just gets delayed (lag)...

    Can this be done with liquidsoap and airtime?

    Using a webstream with icecast is too restrictive for DJs to play on longer or just jump on at 3am!

    Thanks.

    ------EDIT
    Just a flash thought, (although I might be mistaken) could it be the buffer works, as above, but it's seeing the connection drop and then switching to the backup instantly before clearing the buffer!? Perhaps I need to find out how to make airtime exhaust the buffer before any change/switch/transition of audio, even if the encoder disconnect button is pressed, the buffer still needs to be exhausted!

    Thanks Voisses, and/or any other lovely people that care to help! :D

    ------EDIT2
    Nah, I'm wrong, because, the initial change happens in less than 10 seconds, not 45 seconds. Humz..
    Post edited by Jamie at 2014-05-04 03:49:32
  • Vote Up0Vote Down JamieJamie
    Posts: 6Member
    Pretty please, any one have any idea if the audio can be buffered like the picture?

    Thanks! :)
  • Vote Up0Vote Down Voisses TechVoisses Tech
    Posts: 1,423Member
     I Want you to think out of the box and to see the solution lies within your strategy you employed.

    The Two key ways to do this with Audio
    1. Stream to Silence then have something strip the silence (this is what I do).I use Mksafe on my source
    2. Is through a transition either with a jingle  or Station ID. ( listen to any Major Commercial Radio Station on a live broadcast)
    The Concept of buffering  came about when low bandwidth (like dial up and dsl) were about.

    The was never fixed and as you see with flash media it was disastrous because you had three things involved
    • Source
    • Container 
    • Player
    This saw the rise of sending data by chunks or variable bitrate ( hls and ts respectively) where 30 seconds of data is placed in a container then destroyed when send to the media or streamed at different bitrates.

    Most Players do not deal with buffers properly if you notice VLC took a long time for RTMP and HLS.

    So Although this is not entirely a solution either 

    • have your streamers push to a server  like Icecast and use as webstream
    • Have the input server stream to you at a lower bit rate 
    • Have proper connection
    Watch CNN or Any Live Broadcast  sometime when they have a skype connection and you will see almost  there is not many solution to having a bad live source but a strategy as mention above.

    I made this final and yes final suggestion on this matter

    Hope You have been educated and inform so go out and make the decision now,you have the tools.


    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Vote Up0Vote Down JamieJamie
    Posts: 6Member
    Ok, thanks, I appreciate your help. I'll look into striping silence and Mksafe. :) cheers!
  • Vote Up0Vote Down JamieJamie
    Posts: 6Member
    Just in case someone is having the same problem... (I hate when people don't post their solutions!)

    We fixed this, and it turns out that the network was not the cause! For some reason m3w does not always get allocated the processing time it needs and gets held up by other things running on a DJs computer system etc. I think this means it might miss its chance to grab and encode some audio. Airtime then has no audio to play for a moment...

    Our solution was to open the task manager and set the m3w.exe process to "High".

    image

    We found this fixed problems on windows 8 computers as well.

    Macs were OK as they are using nicecast :)
  • Vote Up0Vote Down Voisses TechVoisses Tech
    Posts: 1,423Member
    Let me break a cardinal rule of saying "no more comment".
     I will give you a suggested solution,I cannot code it for you but will give you the steps.

    Senario

    Dj stream to station,connection drop or lost.

    What I want to achieve
    1. If its a low connection,I want to test if I can use use another bit rate ,If not go to a break playlist
    2. It total loss I will go straight to playlist

    For my sake I have 4 different rates (32,64,96,128).If you only have 1 bitrate then  only 1 just use url1, if 2 bitrate,use url1 and url2 etc.

    Please note you can use different streams,the option is yours.

    Here is a self explanatory sample

    # Combine lives and files:
    source1 = fallback(track_sensitive=false,
                 transitions=[url1, url2,url3,url4,transjingles],
                 [url1, url2,url3,url4,playlist])

    # playlist can be my schedule or just something until streams come back alive

    #This playlist can also be a block of drops,promo,station ID etc.

    # tI will use mksafe will produce silence then strip the silence
    # only necessary if the playlist ends

    source1 =mksafe(source1)

    # Use a  strip fallback to remove the silence and to autodj

    "Your code here"

    #End code

    This will solve your quote above and give you a smooth transparent transition.

    it is why I said you have to develop a strategy.

    The solution you propose is because you are having hardware and  software problem.

    You might soon be back.as load read your system.

    Wish You luck

    VOISSES






    Post edited by Voisses Tech at 2014-05-24 12:35:34
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Vote Up0Vote Down Voisses TechVoisses Tech
    Posts: 1,423Member
    Now most people will see this

    2014/05/24 11:49:06 [station2live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station2live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station2live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station2live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station1live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station4live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station4live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:06 [station3live:3] Buffer overrun: Dropping 0.03s.
    2014/05/24 11:49:23 [single_5851:3] Prepared "/dir-path/radio/station/jingles/jingles.mp3" (RID 9).
    2014/05/24 11:49:23 [switch_5979:3] Switch to 2012.
    2014/05/24 11:49:25 [server:3] New client: localhost.
    2014/05/24 11:49:25 [server:3] Client localhost disconnected.

    Notice that within 23s my system lock by playing a jingles then make the switch.
    I have a 20sec delay so that I can remove Things not to go on the Air

    The buffers are just pre-buffers

    Hope I shed more light to it

    VOISSES

    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Vote Up0Vote Down JamieJamie
    Posts: 6Member
    Thanks again Voisses for your help. I have/will look more into that along with your other tutorials.

    Anyone reading this, this m3w encoder was still causing problems.

    The final fix was to use the Butt encoder. It now supports Icecast usernames (as of last month)! Our station is now solid! Butt also pushes meta data for our DJs without a problem! This is a seriously good thing for us!

    For the web spiders... Airtime and Butt encoder now working!

    Cheers :)