FireFly Media Server › Firefly Media Server Forums › Firefly Media Server › General Discussion › Serving a growing MP3 file?
- This topic has 2 replies, 2 voices, and was last updated 15 years, 10 months ago by Anonymous.
-
AuthorPosts
-
07/06/2008 at 8:16 AM #2489AnonymousInactive
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?
Thanx!
– Steinar
07/06/2008 at 9:09 AM #17168fizzeParticipantI 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.
10/06/2008 at 5:56 PM #17169AnonymousInactiveWell, 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 server.name.com “/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.
*/
#include
#include
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) {
++bytecount;
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! */
exit(0);
}
/* File is still growing, wait 10s and try again */
sleep(10);
oldbytecount = bytecount;
}
}
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.