Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Buffering streaming audio
I like to listen to radio stations on the Internet. Usually these are European stations in time zone UTC+1, and I live in timezone UTC-4. In winter this is 5 hours time difference, in summer 6 hours.
It is just not nice to listen to the radio at 8 pm, and then hear the night program of 2 am.
Is there a possibility somehow to buffer these 6 hours of audio, so that I hear everything 6 hours later? I think it would involve writing the stream to disk, and pick up the stream from disk 6 hours later.
It seems that matters are complicated by the variety of different streams and players that are being used. I could easily identify these:
And I would not be surprised if some .wmv is used as well.
If no linux tool exists for this, I might be interested in some general information as well, like "you'd have to write a C-program which does that and that."
The -novideo option really is important. Otherwise mplayer assumes during playback this is a video stream, no matter how much you tell mplayer to use an audio decoder.
I have put this script file in a cron job, which starts to record my favorite programs at a certain time of the day. I record the pid of the process, so some time later, using another cron job I can stop the recording. Four hours of recording from this station yield a file of approximately 130-140 MB, which is quite reasonable.
With again another cron job I start mplayer in playback mode to start the rebroadcast of the recorded file.
The playback of the file can already start when the file is still being recorded, so time shift smaller than total recording time are also possible.
It works very well, however, I take the extra step in converting to .mp3 format and file size is reduce by 1/3 or more depending on the bit-rate you compress too:
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Funny that I was not the only one trying to do this.
I did not feel the need for compressing the stream again, at under 30 MB/hour I don't worry too much about file size.
If you experience that audio quality is decreased after compressing again, do not compress. If you re-encode an already encoded audio stream, this is called transcoding, can seriously decrease audio quality, even if the bitrate would normally provide acceptable audio.
That is because during the first compression, certain parts (which we cannot hear anyway) are removed from the audio information. However, if you encode again with a different algorithm, the algorithm expects full uncompressed audio, not already crippled audio. Lame doesn't warn about this, because it is technically possible to feed an encoder with an already encoded stream.
You can compare this with the editing of a picture in Gimp. If you edit a RAW image, you can easily change brightness, contrast or color balance. If you try to do this with a highly compressed JPG image, results are far worse. This is because in the orginal JPG, all information which was not necessary for showing a nice picture to the human eye was removed. The picture is nice, but doesn't contain any information anymore which allows you to change some parameters while the picture is still being percepted as nice by the human eye.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.