]> pere.pagekite.me Git - homepage.git/blob - blog/Recording_video_from_cron_using_VLC.html
Remember URL to final blog.
[homepage.git] / blog / Recording_video_from_cron_using_VLC.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
5 <title>Petter Reinholdtsen: Recording video from cron using VLC</title>
6 <link rel="stylesheet" type="text/css" media="screen" href="style.css">
7 </head>
8 <body>
9
10 <div class="title">
11 <h1>
12 <a href="">Petter Reinholdtsen</a>
13
14 </h1>
15
16 </div>
17
18
19 <div class="entry">
20 <div class="title">Recording video from cron using VLC</div>
21 <div class="date">2009-04-05 10:00</div>
22 <div class="body">
23 <p>One think I have wanted to figure out for a along time is how to
24 run vlc from cron to do recording of video streams on the net. The
25 task is trivial with mplayer, but I do not really trust the security
26 of mplayer (it crashes too often on strange input), and thus prefer
27 vlc. I finally found a way to do it today. I spent an hour or so
28 searching the web for recipes and reading the documentation. The
29 hardest part was to get rid of the GUI window, but after finding the
30 dummy interface, the command line finally presented itself:</p>
31
32 <blockquote><pre>URL=http://www.ping.uio.no/video/rms-oslo_2009.ogg
33 SAVEFILE=rms.ogg
34 DISPLAY= vlc -q $URL \
35 --sout="#duplicate{dst=std{access=file,url='$SAVEFILE'},dst=nodisplay}" \
36 --intf=dummy</pre></blockquote>
37
38 <p>The command stream the URL and store it in the SAVEFILE by
39 duplicating the output stream to "nodisplay" and the file, using the
40 dummy interface. The dummy interface and the nodisplay output make
41 sure no X interface is needed.</p>
42
43 <p>The cron job then need to start this job with the appropriate URL
44 and file name to save, sleep for the duration wanted, and then kill
45 the vlc process with SIGTERM. Here is a complete script
46 <tt>vlc-record</tt> to use from <tt>at</tt> or <tt>cron</tt>:</p>
47
48 <blockquote><pre>#!/bin/sh
49 set -e
50 URL="$1"
51 SAVEFILE="$2"
52 DURATION="$3"
53 DISPLAY= vlc -q "$URL" \
54 --sout="#duplicate{dst=std{access=file,url='$SAVEFILE'},dst=nodisplay}" \
55 --intf=dummy < /dev/null > /dev/null 2>&1 &
56 pid=$!
57 sleep $DURATION
58 kill $pid
59 wait $pid</pre></blockquote>
60 </div>
61
62 <div class="tags">Tags: <a href="tags/english">english</a>, <a href="tags/nuug">nuug</a>, <a href="tags/video">video</a>.</div>
63
64 </div>
65
66
67
68
69
70
71 <div id="sidebar">
72
73 <h2>Archive</h2>
74 <ul>
75
76 <li>2010
77 <ul>
78
79 <li><a href="archive/2010/01/">January (2)</a></li>
80
81 <li><a href="archive/2010/02/">February (1)</a></li>
82
83 <li><a href="archive/2010/03/">March (3)</a></li>
84
85 <li><a href="archive/2010/04/">April (3)</a></li>
86
87 <li><a href="archive/2010/05/">May (1)</a></li>
88
89 </ul></li>
90
91 <li>2009
92 <ul>
93
94 <li><a href="archive/2009/01/">January (8)</a></li>
95
96 <li><a href="archive/2009/02/">February (8)</a></li>
97
98 <li><a href="archive/2009/03/">March (12)</a></li>
99
100 <li><a href="archive/2009/04/">April (10)</a></li>
101
102 <li><a href="archive/2009/05/">May (9)</a></li>
103
104 <li><a href="archive/2009/06/">June (3)</a></li>
105
106 <li><a href="archive/2009/07/">July (4)</a></li>
107
108 <li><a href="archive/2009/08/">August (3)</a></li>
109
110 <li><a href="archive/2009/09/">September (1)</a></li>
111
112 <li><a href="archive/2009/10/">October (2)</a></li>
113
114 <li><a href="archive/2009/11/">November (3)</a></li>
115
116 <li><a href="archive/2009/12/">December (3)</a></li>
117
118 </ul></li>
119
120 <li>2008
121 <ul>
122
123 <li><a href="archive/2008/11/">November (5)</a></li>
124
125 <li><a href="archive/2008/12/">December (7)</a></li>
126
127 </ul></li>
128
129 </ul>
130
131
132
133 <h2>Tags</h2>
134 <ul>
135
136 <li><a href="tags/3d-printer">3d-printer (11)</a></li>
137
138 <li><a href="tags/amiga">amiga (1)</a></li>
139
140 <li><a href="tags/aros">aros (1)</a></li>
141
142 <li><a href="tags/debian">debian (14)</a></li>
143
144 <li><a href="tags/debian edu">debian edu (15)</a></li>
145
146 <li><a href="tags/english">english (24)</a></li>
147
148 <li><a href="tags/fiksgatami">fiksgatami (1)</a></li>
149
150 <li><a href="tags/fildeling">fildeling (6)</a></li>
151
152 <li><a href="tags/kart">kart (2)</a></li>
153
154 <li><a href="tags/lenker">lenker (1)</a></li>
155
156 <li><a href="tags/ltsp">ltsp (1)</a></li>
157
158 <li><a href="tags/multimedia">multimedia (5)</a></li>
159
160 <li><a href="tags/norsk">norsk (64)</a></li>
161
162 <li><a href="tags/nuug">nuug (71)</a></li>
163
164 <li><a href="tags/opphavsrett">opphavsrett (12)</a></li>
165
166 <li><a href="tags/personvern">personvern (11)</a></li>
167
168 <li><a href="tags/reprap">reprap (10)</a></li>
169
170 <li><a href="tags/rss">rss (1)</a></li>
171
172 <li><a href="tags/sikkerhet">sikkerhet (7)</a></li>
173
174 <li><a href="tags/standard">standard (11)</a></li>
175
176 <li><a href="tags/stavekontroll">stavekontroll (1)</a></li>
177
178 <li><a href="tags/video">video (10)</a></li>
179
180 <li><a href="tags/vitenskap">vitenskap (1)</a></li>
181
182 <li><a href="tags/web">web (6)</a></li>
183
184 </ul>
185
186 </div>
187 </body>
188 </html>