If any of you are like me, you like to listen to (a) live radio stream(s) from several different journalistic or opinion talk shows oftentimes along your breakfast, brunch, lunch, snack, tea, dinner or supper coffee or... Mate for my fellow Rioplatense latinos.
If any of you had a hard time making the Streamripper suggested Tip
work, like I had, I believe this one new ACME TrickTip™
will be well received. (Cheers to the folks at the previous topic who inspire this one).
If you also had a hard time coping with the Template Editor
and flexibility of the metadata items provided in there, this ACME TrickTip™
will serve you well to customize your resulting output file, whatever the input is, provided it is supported for encoding by the FFmpeg
library, which is very well supported itself.
These are pretty simple steps to follow to get your thing working in no time.1.
Download the Windows binary build of FFmpeg provided at: https://ffmpeg.org/download.html#build-windows2.
Place the ffmpeg.exe
binary executable that can be found within the build you downloaded wherever you like to and remember
where you placed that, (make sure MusicBee can access it)
Get to MusicBee Preferences -> Tools. For the Application Path
you will reference the ffmpeg.exe from before.4.
Now comes the trickery and treatery. You can use FFmpeg to include a timestamp in the resulting output file. Use the strftime
feature for this. For example, you can use the following for parameters
-i <URL> -f segment -strftime 1 -segment_time 10:00:00 "Z:\media\radio\<TITLE> - %Y-%m-%d.ogg"
This will save the recorded stream with a filename that includes the title for the stream, followed by the current year, month and date. You can change the date/time format using a strftime
compatible string.A few notes about codec formats, containers and strftime:
- As far as I could research this, from the comments beneath the FFmpeg source code, for certain configurations, strftime may cause strings that are too long to handle for the design of the functions running underneath, therefore my conclusion is nobody has ventured into extending support for widespread usage of strftime on other muxers but segment
(Apple HTTP Live Streaming muxer). This is notably the case for MP3 as support is provided by the LAME libraries and not FFmpeg itself.
- Since strftime
is only supported for these within FFmpeg, for this design you are required to specify -f segment
within the parameters, along with a -segment_time
that is greater than or equal to the duration of the show you are to record.
- The actual purpose of segment is to provide "automated stream segmenting". Meaning that whatever time you choose for -segment_time
will be the duration of each
segment of the stream you are recording.
- Using a -segment_time
longer than the duration of the show, makes it so that it will record a single file until you stop the execution of the FFmpeg instance.
- The parameters "code example" provided above use OGG for container. As far as I could research, this defaults to using libvorbis for encoder. Which in turn defaults to using variable bit-rate.
- As far as I could research this, the encoder to be used is extrapolated from the format you use on the name of the resulting file.
- As mentioned for .ogg
the encoder used is libvorbis
. For .opus
file formats, the encoder used is libopus
. Both of these have VBR for default.
- For .aac
the encoder used is FFmpeg's native aac
implementation. For .mp3
the encoder used is libmp3lame
. Both of these seem
to have a CBR 128kbps value (again, as far as I could research this).
- You can setup multiple "External Tools" with these different formats, for different use cases.
- I have been unable to customize the output beyond what is described here, however I will not continue to pursue that path for the time being, as I accomplished what I wanted personally, and it has already driven me mad for like 7 hours.
- If anyone wants to contribute and shed some light on other combinations, please do so, I can see how there are infinite possible use cases and possibly infinite users looking for their unique solution.
The freaking bibliography:
(for masochists only)https://github.com/FFmpeg/FFmpeghttps://trac.ffmpeg.org/wikihttps://ffmpeg.org/ffmpeg.htmlhttps://ffmpeg.org/ffmpeg-formats.htmlThe most important Stack Overflow answer during this researchhttps://stackoverflow.com/questions/34884493/how-to-make-ffmpeg-insert-timestamp-in-filenamehttps://stackoverflow.com/questions/46978379/ffmpeg-using-current-datetime-in-the-filename-strftime-parameter-doesnt-seemhttps://stackoverflow.com/questions/3255674/convert-audio-files-to-mp3-using-ffmpeghttps://stackoverflow.com/questions/61129758/ffmpeg-strftime-microsecondshttps://stackoverflow.com/questions/59549766/is-there-a-way-to-identify-if-an-audio-is-vbr-or-cbr-using-ffmpeg