Skip to content

Instantly share code, notes, and snippets.

@bgerm
Created June 19, 2013 14:58

Revisions

  1. bgerm created this gist Jun 19, 2013.
    27 changes: 27 additions & 0 deletions record.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/bin/sh

    # Record web camera activity in a cron job using VLC.
    # This is in a script so that I don't have to go through
    # the vlc man pages again. Plus, somethings have unexpected
    # behavior, such as requiring --run-time and --stop-time
    # to be run together so it doesn't hang.

    # Camera used: Foscam FI8910W camer

    # Cron
    # */30 1,2,3,4,5,6 * * * ~/streams/record.sh 1680 ~/streams/out/ http://admin:@192.168.2.118/videostream.cgi 2>&1 >> ~/streams/record.log

    if [ $# -ne 3 ]
    then
    echo "Usage: `basename $0` DURATION OUTDIR HTTP_STREAM"
    exit 65
    fi

    dur=$1
    out=${2%/}
    stream=$3

    runtime=$(date +%Y-%m-%d-%H:%M)
    dst=$out/$runtime.ts

    /Applications/VLC.app/Contents/MacOS/VLC -I dummy -v $stream --sout "#standard{access=file,mux=ts,dst=$dst}" --http-reconnect --preferred-resolution 240 --run-time $dur --stop-time $dur vlc://quit