Episode: 4287
Title: HPR4287: Schedule audio recordings on the command line
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4287/hpr4287.mp3
Transcribed: 2025-10-25 22:28:47

---

This is Hacker Public Radio Episode 4287 for Tuesday the 7th of January 2025.
Today's show is entitled, Schedule Audio Recordings on the Command Line.
It is the 20th show of Kevin, and is about 12 minutes long.
It carries a clean flag.
The summary is, Kevin talks about scheduling a recording with a Cron task using FFMPG.
Hello, hello, this is Kevin from the TuxJump podcast, and you're listening to another
episode of HPR.
Now this episode is actually being done in response to my own episode, or maybe a follow-up
subator one, 4249, which was audio streams on the command line, which was released
back on the 14th of November 24.
So in that I spoke about just purely streaming from the command line, and then ripping
the file if you want or recording it to a file.
So and then at the end of the episode I said, it's not that difficult to set up as a Cron
task job.
And the truth is I'd never actually done it, I knew the theory of it, but I hadn't actually
done it or scheduled any recordings, so I started to think, well, wait a minute, it might
be nice to actually show how to do that.
And I started with several different techniques, I mean I started just with ripping a stream
and then killing the process, and I actually wasn't happy with it.
I really didn't like it, I thought, that's a very crude way of doing this.
So what I then started doing was started playing about, and the thing that I actually found
was absolutely perfect for this was a Cron tab.
So those of us who have been using Linux for a while, I imagine quite a few who are comfortable
on the command line are going to have used Cron tab at some point.
Cron tab is just something which schedules a task, that's literally all it does.
It's, I don't worry, I'm not saying you have to build up your own Linux system and
schedule everything, schedule backups, schedule updates, whatever.
No, no, this is just custom stuff.
So if you like something or want something done at a specific time, then you can do that
very easily setting up on the setting up of the Cron tab.
Now to do this for, I'm not going to go over using Cron tab, I'm going to just purely
go over how to record a stream.
So there's two bits of information you need to know before you actually open up and start
this new Cron tab.
First of all, you've got to have the URL feed for the radio stream that you're playing.
Either that's a must, you have to have that.
If you're not sure where it is, they're not usually too difficult to find, but sometimes
they're not immediately obvious.
So you might have to go look around, I quite like for ones that I'm struggling with
is I've got an app called transistor, which finds radio stations.
That's on my Android phone.
It finds radio stations and then it finds very easily just by name.
Then all you need to do is click on it and click on the station, click edit and it actually
gives you the streams straight away.
There's various other sources you can use.
Everybody's got their own ways.
You can use it by inspecting players, very often that's quite a good way, actually, especially
if the website doesn't go to right-click and then click inspect and then you're going
through code.
But that one's a bit of a more time-consuming way, let's see.
So you need that, first of all, you've got to have the stream and then secondly, you need
to know when this is going to be on.
So is it a weekly show?
Is it a monthly show?
Obviously, if this show is like TuxJam, very much haphazard, then it's going to be impossible
to schedule for because yes, we've record kind of roughly monthly, but there's never
a set.
There's never a set time.
So you've got an issue there, but in saying that given we are a podcast, you don't
have to need to reverse the stream.
So those are the two things you need.
So now, so to start up CronTab, just go to a terminal and what we need to do is just
type in CronTab, C-R-O-N-T-A-B, all one word, and then space, and then hyphen E.
And this will bring you up just quite a lengthy spiel, a bit of a page worth, maybe a page
and a half to a new terminal size.
And then it looks like everything's commented out, there's nothing there, and that will
be right, if you've never set up a CronTab before, then there'll not be anything in there.
So everything is just information at present.
So the first thing we're going to need to do is set this time, that's a very first thing.
You need to have a space in between each one.
You can't leave any blank, right?
You have to use an asterisk if you are not going to use anything.
So the first number is your minutes, right?
So it's going to be written 24 hours format, but the wrong way around compared to what
you used to.
The first number is minutes, the second number is hours.
So let's just, I'm going to take, for example, those of us who have been into podcasting
Creative Commons music and Linux for a while will certainly know Dan Lynch.
So he does a radio show on auto, radio, and it's every Thursday night, and he streams
it, but there's no podcast for it, and there's no catch-up service.
So this could be a good example to use.
I know that one's on every Thursday at nine o'clock, so let's just set this up just
now.
Seven o'clock, so I'm going to start with zero, zero, and then a space.
And then seven o'clock, and it's seven pm, so that's 19.
The next one is the day of the month.
So this is a monthly thing.
What day do you want it on?
Well, we don't want to set it on monthly.
We're just, we're looking at weekly.
So that's an asterisk space, and then it's which month do you want it?
Well, actually, I want this every month.
So it's an asterisk.
I've never actually used that for anything to be perfectly honest.
Just said things for specific months.
I have you day of the month, and I've used day of the week, but never individual months.
So I want this every month, so again, that's an asterisk.
Now the days of the week, you've got to be careful with this one.
It starts with Sunday at zero, okay?
So zero is Sunday, Monday's one, Tuesday's two, Wednesday's three, Thursday's four, Friday
is five, Saturday's six, and actually Sunday is seven.
That's well, so you can have Sunday as either zero or seven, right then.
So I want this a seven o'clock on a Thursday.
So it's minutes, zero, zero, then space, and then 19 for seven o'clock, and then a space,
and then asterisk, space, asterisk, space four, and that's going to record it every Thursday.
But we need to put in more than this.
So I'm going to use the FFMP command.
So the FFMP command is the one that I've discovered is the best one for actually pulling
down a stream.
So we're going to go FFMP, and then a space, and then hyphen lowercase i, and then you
need to put the URL in.
That's the next thing.
So the URL of the stream, okay?
And then put a space in, and then minus t, and then a space.
And now we're going to put in how long we want this for.
Now this has got to be three sets of numbers, and it's got to be the average, and then
a colon, and then the minutes, then a colon, then the seconds.
So dance show is two hours.
So zero, two, colon, zero, zero, colon, zero, zero, that's two hours.
And then put in our space, you've got to put down where this is going to be recorded.
And what file you want to save it to.
So I've just got it from my home directory.
I've got a folder they are called recordings.
And I'm just going to call this one, Dan Lynch pick mix, because it's the, I think it's
called the midweek pick mix, something like that as show is.
So I'm going to call that.
So Dan Lynch pick mix dot org, it's most of my files are org anyway.
You can't change that, that could easily be mp3, it's entirely up to you.
You can if you want to use something like flak, however, it's only as good as it's
original.
And I don't believe you'll get very many streams putting out flak quality.
But if you save it as flak, that is going to eat up your desk space, because they will
be big files.
So I personally would recommend either mp3 or org or something, just because you're probably
not going to be any better than that.
What is getting streamed out, the majority of the time, there will be some exceptions
to that rule.
And literally that's it.
So now what you want to do is you've got your command in there.
If you want to set up another recording, that's fine, you can just make sure, as with
any crontab, a job you need to go to the next line, so it returns with a drops align,
otherwise it won't carry it out.
It'll try everything in one command.
So once you've come out of it, make sure you've saved it.
Now let's just double check this.
So type in crontab, space, hyphen L, lowercase L. And that will actually show you the tasks
that are coming up.
And hopefully you should see, so I've just done this one.
So it's seven o'clock on the first day, it gives me the command, the stream for the
radio station, then the time, and then where I want it to be.
So yeah, so that's it.
It's all there.
Now, others thing I would actually point out as well is, and it's funny, it's one of
those things that you don't actually think about mentioning until afterwards when somebody
complains that this hasn't worked.
This will not do it if your computer is switched off.
So your computer has got to be switched on for this.
So if you're in the habit of maybe like say, you want to listen to this, but it's not
something that you would ever have on, then you know, if it's, if you don't really have
your computer on regularly, then maybe you might want to set this up on a pie or something
to do it every week, or just, you know, set a reminder on your phone, you know, right?
It's Thursday, it's haphastics, switch on your computer.
So yeah, so that's essentially a nice simple and actually fairly elegant way to again, set
up a recording on the command line, no graphical interface, and you will be left each week
with a new audio file.
So this is Kavi for Hacker Public Radio, and encouraging each and every one of you to
please submit a show because things are a bit lower this present, and you know the
motto when we run it as shows, that's it, Hacker Public Radio ceases.
So please do, doesn't have to be anything spectacular in audio production quality, all you need
is a phone or any device or a microphone, and the ability to upload it to the internet.
So please can I encourage each and every one of you?
So given this is my first show of 2025, I will say happy new year and all the best.
You have been listening to Hacker Public Radio at Hacker Public Radio, doesn't work.
Today's show was contributed by a HBR listener like yourself, if you ever thought of recording
a podcast, then click on our contribute link to find out how easy it really is.
Hosting for HBR has been kindly provided by an honesthost.com, the Internet Archive
and our Sync.net.
On the Sadois status, today's show is released on our Creative Commons, Attribution 4.0 International
License.
