Hi,

Thanks for your answer, it is exactly what I was looking for! :D

I used reopen_when={0s} to create 1 minute files but this time doesn’t
seem to be precisely respected (especially for the first time the clock
reaches 00 seconds).
I can’t find any documentation about the reopen_when parametter, what is
the expected precision ?

Have a nice sunday :)
Adrian

On Mon, Apr 17, 2023 at 09:08:25AM -0500, Romain Beauxis wrote:
>    Hi Adrian,
>    Filenames can be functions that are executed every time the file is
>    created, something like this:
>    ```
>    def my_filename() =
>      "/archive/#{int_of_float(gettimeofday())}.mp3"
>    end
>    ```
>    For simple functions like that, we have a simplified syntax that allows
>    to write them in a short way:
>    ```
>    my_filename = {"/archive/#{int_of_float(gettimeofday())}.mp3"}
>    ```
>    So, in your case, all you should have to do to make the
>    filename dynamic in your example is surround it with { }:
>    ```
>    output.file(
>      %mp3,
>      {"/archive/#{int_of_float(gettimeofday())}.mp3"},
>      s,
>      reopen_when={0m}
>    )
>    ```
>    If you want to read a more detailed presentation of the language and
>    more, I can recommend the liquidsoap
>    book: [1]https://www.liquidsoap.info/doc-dev/book.html
> 
>    Le dim. 16 avr. 2023 à 08:42, Adrian <[2]nii...@gmx.com> a écrit :
> 
>      Hi everyone and thanks a lot for your work!
>      I'm trying to adapt the cookbook example "Dump a stream into
>      segmented
>      files".
>      I'd like to have the filename containing the unix timestamp (or
>      epoch),
>      but I don't know what are the possibles "time literals" mentioned in
>      the
>      cookbook:
>      [3]https://www.liquidsoap.info/doc-2.1.4/cookbook.html#dump-a-stream
>      -into-segmented-files
>      What I'm trying to achieve looks like this:
>      output.file(%mp3, '/archive/%s.mp3', s, reopen_when={0m})
>      Where %s would be replaced by the unix timestamp (%s taken from the
>      date
>      command) but unfortunately, %s is not a "time literal". Plus, I
>      can't find any
>      definition or list of "time literals" anywhere in the doc or in the
>      source code.
>      I managed to get the unix timestamp in my filename with:
>      output.file(%mp3, '/archive/#{int_of_float(gettimeofday())}.mp3', s,
>      reopen_when={0m})
>      But the time is evaluated at the string creation and not a each file
>      opening.
>      Is it possible for you to document the "time literals"?
>      Where can I find this list? And where can I add some new literals if
>      needed?
>      Thank you for your time,
>      Niilos
>      _______________________________________________
>      Savonet-users mailing list
>      [4]Savonet-users@lists.sourceforge.net
>      [5]https://lists.sourceforge.net/lists/listinfo/savonet-users
> 
> References
> 
>    1. https://www.liquidsoap.info/doc-dev/book.html
>    2. mailto:nii...@gmx.com
>    3. 
> https://www.liquidsoap.info/doc-2.1.4/cookbook.html#dump-a-stream-into-segmented-files
>    4. mailto:Savonet-users@lists.sourceforge.net
>    5. https://lists.sourceforge.net/lists/listinfo/savonet-users


> _______________________________________________
> Savonet-users mailing list
> Savonet-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/savonet-users



_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to