Ubuntu – Schedule to record video stream in VLC

cronstreamingvideo-recordingvlc

I work at a school and have setup a workstation to broadcast/stream the morning announcements for the teachers and kiddos. Teachers in the classroom access this stream via Windows Media Player or VLC…however, sometimes the teacher is running late, or their computer is having issues, so as a courtesy, I record them from my Ubuntu machine through VLC's magical red record button. From there, I upload them to a Google Drive folder that they have access to and problem solved. However, I am not always in my office first thing in the morning (resulting in some days without recordings).

The announcements start at the same time every day (that is, M-F) at 7:55 and run to about 8:05 (5~10 minutes depending on how much content there is).

Can someone please help me with a cron/command/script for VLC to automatically record our announcements daily at the specified time?

Best Answer

You can use two cron lines like this to make a ~10 minute recording from 0755.

55 7 * * 1-5  cvlc --run-time=5 --sout file/ts:stream.mp4 htsp://@ip:9982/211
5  8 * * 1-5  sh -c "killall cvlc; cp stream.mp4 /path/to/upload"

I've added 1-5 in the fifth field so it only runs Monday to Friday.

VLC is hard to stop recording without actual controls. The easiest way it to just tell it to die. That's what the second line does... And then does something (up to you) with the saved file.


There is a small problem in that the teacher is going to have to skip to the right moment... What if the video is longer than 10 minutes one day? The best possible solution is going to involve somebody making the video having manual control.