e2e/bin/safaridriver.sh (view raw)
1#!/bin/sh
2
3if [ "$1" = -t ]; then
4 BIN='/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
5 shift
6else
7 BIN=safaridriver
8fi
9
10SCREEN='Capture screen'
11
12if [ -z "$1" ]; then
13 OUTPUT=$(ffmpeg -f avfoundation -list_devices true -i - 2>&1 | grep "$SCREEN")
14 if [ "$(echo "$OUTPUT" | grep -c ^)" -gt 1 ]; then
15 echo 'Please select the input device by entering its [index] number:' >&2
16 echo "$OUTPUT" >&2
17 read -r INDEX
18 fi
19else
20 INDEX=$1
21fi
22
23echo 'Starting safaridriver on 127.0.0.1:4444 ...' >&2
24"$BIN" -p 4444 & pid=$!
25
26# shellcheck disable=SC2064
27trap "kill $pid; exit" INT TERM
28
29echo 'Starting mjpeg-server on 127.0.0.1:9000 ...' >&2
30mjpeg-server -a 127.0.0.1:9000 -- ffmpeg \
31 -loglevel error \
32 -probesize 32 \
33 -fpsprobesize 0 \
34 -analyzeduration 0 \
35 -fflags nobuffer \
36 -f avfoundation \
37 -capture_cursor 1 \
38 -r "${FPS:-15}" \
39 -pixel_format yuyv422 \
40 -i "${INDEX:-$SCREEN}" \
41 -f mpjpeg \
42 -q "${QUALITY:-2}" \
43 -