blob: bb0ca152ae9241feed2cd9888f5eafe499e618a0 (
plain)
- #!/bin/sh
- #
- # Usage: livedump [FORMAT [BASESTEM [SESSIONPATTERN [SEGMENTPATTERN]]]]
- #
- # Patterns are fed through "date +PATTERN"
- #
- # Examples: livedump
- # livedump dv ./dump /%Y%m%d/%H%M%S /%H%M%S
- # livedump dv-avi
- #
- # First two examples effectively identical, using defaults.
- # Third example using AVI container instead
- #
- # 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}
- BASESTEM=${2:-./dump}
- SESSIONPATTERN=${3:-/%Y%m%d/%H%M%S}
- SEGMENTPATTERN=${4:-/%H%M%S}
- case $FORMAT in
- isight-nut)
- set -- -f libdc1394 -video_size 640x480 -framerate 15 -thread_queue_size 256 -i foo \
- -f alsa -thread_queue_size 2048 -i default:CARD=iSight \
- -f nut -codec copy -f_strict experimental -syncpoints timestamped -write_index 0
- SUFFIX=nut
- ;;
- dv)
- set -- -f iec61883 -i auto \
- -f dv -codec copy
- SUFFIX=dv
- ;;
- dv-avi)
- set -- -f iec61883 -i auto \
- -f avi -codec copy
- SUFFIX=avi
- ;;
- dv-nut)
- set -- -f iec61883 -i auto \
- -f nut -codec copy -f_strict experimental -syncpoints timestamped -write_index 0
- SUFFIX=nut
- ;;
- esac
- LINKPATH="$BASESTEM.$SUFFIX"
- SESSIONSTEM=$(date +"$SESSIONPATTERN")
- SESSIONPATH="$BASESTEM$SESSIONSTEM.$SUFFIX"
- mkdir -p "$(dirname "$LINKPATH")" "$(dirname "$SESSIONPATH")"
- touch "$SESSIONPATH"
- [ -z "$LINKPATH" ] | ln -fs "$SESSIONPATH" "$LINKPATH"
- while true; do
- SEGMENTSTEM=$(date +"$SEGMENTPATTERN")
- LOGPATH="$BASESTEM$SESSIONSTEM$SEGMENTSTEM.log"
- mkdir -p "$(dirname "$LOGPATH")"
- FFREPORT="file=$LOGPATH" \
- ffmpeg -hide_banner "$@" pipe: \
- >> "$SESSIONPATH"
- done
|