1 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
2 <rss version='
2.0' xmlns:lj='http://www.livejournal.org/rss/lj/
1.0/'
>
4 <title>Petter Reinholdtsen - Entries from April
2009</title>
5 <description>Entries from April
2009</description>
10 <title>Recording video from cron using VLC
</title>
11 <link>../../../Recording_video_from_cron_using_VLC.html
</link>
12 <guid isPermaLink=
"true">../../../Recording_video_from_cron_using_VLC.html
</guid>
13 <pubDate>Sun,
5 Apr
2009 10:
00:
00 +
0200</pubDate>
15 <p
>One think I have wanted to figure out for a along time is how to
16 run vlc from cron to do recording of video streams on the net. The
17 task is trivial with mplayer, but I do not really trust the security
18 of mplayer (it crashes too often on strange input), and thus prefer
19 vlc. I finally found a way to do it today. I spent an hour or so
20 searching the web for recipes and reading the documentation. The
21 hardest part was to get rid of the GUI window, but after finding the
22 dummy interface, the command line finally presented itself:
</p
>
24 <blockquote
><pre
>URL=http://www.ping.uio.no/video/rms-oslo_2009.ogg
26 DISPLAY= vlc -q $URL \
27 --sout=
"#duplicate{dst=std{access=file,url=
'$SAVEFILE
'},dst=nodisplay}
" \
28 --intf=dummy
</pre
></blockquote
>
30 <p
>The command stream the URL and store it in the SAVEFILE by
31 duplicating the output stream to
"nodisplay
" and the file, using the
32 dummy interface. The dummy interface and the nodisplay output make
33 sure no X interface is needed.
</p
>
35 <p
>The cron job then need to start this job with the appropriate URL
36 and file name to save, sleep for the duration wanted, and then kill
37 the vlc process with SIGTERM. Here is a complete script
38 <tt
>vlc-record
</tt
> to use from
<tt
>at
</tt
> or
<tt
>cron
</tt
>:
</p
>
40 <blockquote
><pre
>#!/bin/sh
43 SAVEFILE=
"$
2"
44 DURATION=
"$
3"
45 DISPLAY= vlc -q
"$URL
" \
46 --sout=
"#duplicate{dst=std{access=file,url=
'$SAVEFILE
'},dst=nodisplay}
" \
47 --intf=dummy
< /dev/null
> /dev/null
2>&1 &
51 wait $pid
</pre
></blockquote
>