You are here: Home » Topic » Serving a growing MP3 file?

Serving a growing MP3 file?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #2489

    On a server at work I have a cronjob that uses curl, against a streaming server, to record a program I would like to listen to, that starts before I get to work in the morning.

    I use my laptop to listen to the program, and I carry the laptop between work and home. My laptop isn’t booted at work until after the program has started.

    To listen to all of it unbroken, I currently have to wait until the recording completes, and then download it to my laptop.

    Is it possible to use Firefly to serve out the growing mp3 file?


    – Steinar


    I guess thats not a problem.
    The client will receive invalid duration tags and metadata, but that’s a given.
    Transcoding happens live thru pipes (on some machines at least) and that works just as well. So technically it’s not a problem. 🙂

    Just on a sidenote: I’ve been trying the same thing with a ogg-vorbis stream. This is tricky because it is split up in hundreds of metastreams, which most clients have troubles decoding, and transcoding is itchy also.


    Well, I found a simple solution that doesn’t involve Firefly, or any other server software (except ssh), and may be of interest of others, so I’ll post it here.

    I wrote a small C program called growcat, see below, that can be used in the following way:

    (ssh “/path/to/growcat /path/to/file/to/stream.mp3”) >localfile.mp3

    The code of the program, is:

    * Read a file and output to standard out. If the file ends,
    * don't terminate, but instead hang, waiting for new input.

    main(int argc, const char* argv[]) {
    * The first arg, if any, is expected to be the input file name
    * if there are no arguments, stdin is used as the input file.
    FILE* infile = stdin;
    if (argc > 0) {
    const char* filename = argv[1];
    infile = fopen(filename, "r");

    * Loop forever, wait for a while when the end of the input
    * file is reached.
    int bytecount = 0;
    int oldbytecount = 0;
    while(1) {
    int c = fgetc(infile);
    while (c != EOF) {
    fputc(c, stdout);
    c = fgetc(infile);
    /* EOF reached, first check if it has stopped growing */
    if (oldbytecount == bytecount) {
    /* file has stopped growing and EOF is reached. Terminating! */
    /* File is still growing, wait 10s and try again */
    oldbytecount = bytecount;
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.