<commit_before>#!/bin/sh

#/ Usage: gst-launch-start-stop.sh <video-device>
#/
#/ Captures video from the Hauppauge HDPVR for ~25 seconds; stops and repeats.
#/ This is to attempt to reproduce an HDPVR lock-up.
#/
#/ Arguments:
#/
#/   video-device     The device node for the HDPVR to test, e.g. /dev/video1

usage() { grep '^#/' "$0" | cut -c4-; }  # Print the above usage message.

[ $# -eq 1 ] || { usage >&2; exit 1; }
dev="$1"

timestamp() { date '+%b %d %H:%M:%S'; }

while \
    echo "$(timestamp) gst-launch started"; \
    gst-launch -eq \
        v4l2src num-buffers=5000 "device=$dev" ! mpegtsdemux ! video/x-h264 ! \
        decodebin2 ! ffmpegcolorspace ! fakesink sync=false
do
   echo "$(timestamp) gst-launch ended"
   sleep 5
done
<commit_msg>Time out the gst-launch command if it hangs<commit_after>#!/bin/sh

#/ Usage: gst-launch-start-stop.sh <video-device>
#/
#/ Captures video from the Hauppauge HDPVR for ~25 seconds; stops and repeats.
#/ This is to attempt to reproduce an HDPVR lock-up.
#/
#/ Arguments:
#/
#/   video-device     The device node for the HDPVR to test, e.g. /dev/video1

usage() { grep '^#/' "$0" | cut -c4-; }  # Print the above usage message.

[ $# -eq 1 ] || { usage >&2; exit 1; }
dev="$1"

timestamp() { date '+%b %d %H:%M:%S'; }

while true; do
    echo "$(timestamp) gst-launch started"
    timeout 60s gst-launch -eq \
        v4l2src num-buffers=5000 "device=$dev" ! mpegtsdemux ! video/x-h264 ! \
        decodebin2 ! ffmpegcolorspace ! fakesink sync=false
    ret=$?
    case $ret in
        124) echo "$(timestamp) gst-launch timed out";;
        *)   echo "$(timestamp) gst-launch returned $ret";;
    esac
    sleep 5
done

{'fraction_non_alphanumeric': 0.16021441334127456, 'fraction_numerical': 0.026801667659321026, 'mean_word_length': 2.835616438356164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746059', 'n_tokens_mistral': 676, 'n_tokens_neox': 624, 'n_words': 188}