summaryrefslogtreecommitdiff
path: root/bin/livedump
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-08 14:01:25 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-08 14:01:25 +0200
commit19c60a7c2b3115f37a107b5fd939bbdaba44ce6e (patch)
tree3c136968a72a20974d9eceaece4380619fcb6f8d /bin/livedump
Initial draft of script livedump.
Diffstat (limited to 'bin/livedump')
-rwxr-xr-xbin/livedump48
1 files changed, 48 insertions, 0 deletions
diff --git a/bin/livedump b/bin/livedump
new file mode 100755
index 0000000..77b2add
--- /dev/null
+++ b/bin/livedump
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Usage: livedump [FORMAT [BASEPATH [SESSIONPATTERN [SEGMENTPATTERN]]]]
+#
+# Patterns are fed through "date +PATTERN"
+#
+# Examples: livedump
+# livedump dv ./dump /%Y%m%d/%H%M%S /%H%M%S
+#
+# (examples are effectively identical, the latter showing defaults)
+#
+# Description: Save live source to file and append if interupted.
+# By default captures IEC61883 DVCPRO stream from IEEE1394 (Firewire)
+# device, some of which apparently sustaining streams max. 17 minutes.
+#
+# Depends: ffmpeg
+
+set -eu
+
+FORMAT=${1:-dv}
+BASEPATH=${2:-./dump}
+SESSIONPATTERN=${3:-/%Y%m%d/%H%M%S}
+SEGMENTPATTERN=${4:-/%H%M%S}
+
+case $FORMAT in
+ dv)
+ set -- \
+ -f iec61883 -i auto \
+ -f dv -timecode "$(date +%H:%M:%S.00)" -codec copy
+ SUFFIX=dv
+ ;;
+esac
+
+LINKPATH="$LINKSTEM.$SUFFIX"
+SESSIONSTEM=$(date +"$TARGETPATTERN")
+SESSIONPATH="$SESSIONSTEM.$SUFFIX"
+
+mkdir -p "$(dirname "$LINKPATH" "$SESSIONPATH")"
+touch "$SESSIONPATH"
+[ -z "$LINKPATH" ] | ln -fs "$SESSIONPATH" "$LINKPATH"
+while true; do
+ SEGMENTSTEM=$(date +"$SEGMENTPATTERN")
+ LOGPATH="$BASEPATH$SESSIONSTEM$SEGMENTSTEM.log"
+ mkdir -p "$LOGPATH"
+ FFREPORT="file=$LOGPATH" \
+ ffmpeg -hide_banner "$@" pipe: \
+ >> "$SESSIONPATH"
+done