]> pere.pagekite.me Git - homepage.git/commitdiff
Ny posting.
authorPetter Reinholdtsen <pere@hungry.com>
Sun, 5 Apr 2009 09:50:49 +0000 (09:50 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Sun, 5 Apr 2009 09:50:49 +0000 (09:50 +0000)
blog/data/2009-04-05-vlc-opptak.txt [new file with mode: 0644]

diff --git a/blog/data/2009-04-05-vlc-opptak.txt b/blog/data/2009-04-05-vlc-opptak.txt
new file mode 100644 (file)
index 0000000..fd57310
--- /dev/null
@@ -0,0 +1,40 @@
+Title: Recording video from cron using VLC
+Tags: english, nuug, video
+Date: 2009-04-05 10:00
+
+<p>One think I have wanted to figure out for a along time is how to
+run vlc from cron to do recording of video streams on the net.  The
+task is trivial with mplayer, but I do not really trust the security
+of mplayer (it crashes too often on strange input), and thus prefer
+vlc.  I finally found a way to do it today.  I spent an hour or so
+searching the web for recipes and reading the documentation.  The
+hardest part was to get rid of the GUI window, but after finding the
+dummy interface, the command line finally presented itself:</p>
+
+<blockquote><pre>URL=http://www.ping.uio.no/video/rms-oslo_2009.ogg
+SAVEFILE=rms.ogg
+DISPLAY= vlc -q $URL \
+  --sout="#duplicate{dst=std{access=file,url='$SAVEFILE'},dst=nodisplay}" \
+  --intf=dummy</pre></blockquote>
+
+<p>The command stream the URL and store it in the SAFEFILE by
+duplicating the output stream to "nodisplay" and the file, using the
+dummy interface.</p>
+
+<p>The cron job then need to start this job with the approporiate URL
+and file name to save, sleep for the duration wanted, and then kill
+the vlc process with SIGTERM.  Here is a complete script
+<tt>vlc-record</tt> to use from <tt>at</tt> or <tt>cron</tt>:</p>
+
+<blockquote><pre>#!/bin/sh
+set -e
+URL="$1"
+SAVEFILE="$2"
+DURATION="$3"
+DISPLAY= vlc -q "$URL" \
+  --sout="#duplicate{dst=std{access=file,url='$SAVEFILE'},dst=nodisplay}" \
+  --intf=dummy < /dev/null > /dev/null 2>&1 &
+pid=$!
+sleep $DURATION
+kill $pid
+wait $pid</pre></blockquote>