]> pere.pagekite.me Git - homepage.git/blob - blog/Recording_video_from_cron_using_VLC.html
Generated.
[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>2009
77 <ul>
78
79 <li><a href="archive/2009/01/">January (8)</a></li>
80
81 <li><a href="archive/2009/02/">February (8)</a></li>
82
83 <li><a href="archive/2009/03/">March (12)</a></li>
84
85 <li><a href="archive/2009/04/">April (10)</a></li>
86
87 <li><a href="archive/2009/05/">May (9)</a></li>
88
89 <li><a href="archive/2009/06/">June (3)</a></li>
90
91 <li><a href="archive/2009/07/">July (3)</a></li>
92
93 </ul></li>
94
95 <li>2008
96 <ul>
97
98 <li><a href="archive/2008/11/">November (5)</a></li>
99
100 <li><a href="archive/2008/12/">December (7)</a></li>
101
102 </ul></li>
103
104 </ul>
105
106
107
108 <h2>Tags</h2>
109 <ul>
110
111 <li><a href="tags/3d-printer">3d-printer (11)</a></li>
112
113 <li><a href="tags/amiga">amiga (1)</a></li>
114
115 <li><a href="tags/aros">aros (1)</a></li>
116
117 <li><a href="tags/debian">debian (13)</a></li>
118
119 <li><a href="tags/debian edu">debian edu (7)</a></li>
120
121 <li><a href="tags/english">english (14)</a></li>
122
123 <li><a href="tags/fiksgatami">fiksgatami (1)</a></li>
124
125 <li><a href="tags/fildeling">fildeling (3)</a></li>
126
127 <li><a href="tags/lenker">lenker (1)</a></li>
128
129 <li><a href="tags/ltsp">ltsp (1)</a></li>
130
131 <li><a href="tags/multimedia">multimedia (5)</a></li>
132
133 <li><a href="tags/norsk">norsk (51)</a></li>
134
135 <li><a href="tags/nuug">nuug (50)</a></li>
136
137 <li><a href="tags/opphavsrett">opphavsrett (5)</a></li>
138
139 <li><a href="tags/personvern">personvern (8)</a></li>
140
141 <li><a href="tags/reprap">reprap (10)</a></li>
142
143 <li><a href="tags/rss">rss (1)</a></li>
144
145 <li><a href="tags/sikkerhet">sikkerhet (2)</a></li>
146
147 <li><a href="tags/standard">standard (7)</a></li>
148
149 <li><a href="tags/stavekontroll">stavekontroll (1)</a></li>
150
151 <li><a href="tags/video">video (9)</a></li>
152
153 <li><a href="tags/vitenskap">vitenskap (1)</a></li>
154
155 <li><a href="tags/web">web (4)</a></li>
156
157 </ul>
158
159 </div>
160 </body>
161 </html>