Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #320 from aandryashin/master
Browse files Browse the repository at this point in the history
Enabled sound with pulseaudio.
  • Loading branch information
vania-pooh authored Dec 7, 2020
2 parents 0afa18a + 8804978 commit 4e9270d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e
github.com/fatih/color v1.9.0 // indirect
github.com/markbates/pkger v0.17.0
github.com/markbates/pkger v0.17.1
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/spf13/cobra v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/markbates/pkger v0.17.0 h1:RFfyBPufP2V6cddUyyEVSHBpaAnM1WzaMNyqomeT+iY=
github.com/markbates/pkger v0.17.0/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno=
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
Expand Down
4 changes: 3 additions & 1 deletion selenium/video/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arch="all"
license="LGPL-2.1-or-later GPL-2.0-or-later"
makedepends="gnutls-dev lame-dev libvorbis-dev xvidcore-dev zlib-dev libvdpau-dev
imlib2-dev x264-dev libtheora-dev coreutils bzip2-dev perl-dev libvpx-dev
libvpx-dev sdl2-dev libxfixes-dev libva-dev v4l-utils-dev yasm opus-dev libass-dev"
libvpx-dev sdl2-dev libxfixes-dev libva-dev v4l-utils-dev yasm opus-dev libass-dev pulseaudio-dev"
source="https://ffmpeg.org/releases/ffmpeg-$pkgver.tar.xz
0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch
"
Expand All @@ -31,6 +31,7 @@ build() {
--enable-avfilter \
--enable-gpl \
--enable-libx264 \
--enable-libpulse \
--enable-static \
--enable-small \
--disable-ffplay \
Expand All @@ -54,6 +55,7 @@ build() {
--disable-librtmp \
--disable-devices \
--enable-indev=xcbgrab \
--enable-indev=pulse \
$_asm $_dbg
make
}
Expand Down
2 changes: 1 addition & 1 deletion selenium/video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ USER root

FROM alpine:3.12

RUN apk add -U x264-libs sdl2 libxcb libbz2 xset && \
RUN apk add -U x264-libs sdl2 libxcb libbz2 xset pulseaudio-utils && \
rm -rf /var/cache/apk/*
COPY --from=0 /home/selenoid/aports/community/ffmpeg/src/ffmpeg-4.3/ffmpeg /usr/bin/ffmpeg

Expand Down
14 changes: 13 additions & 1 deletion selenium/video/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ HIDE_CURSOR=${HIDE_CURSOR:-""}
if [ -n "$HIDE_CURSOR" ]; then
INPUT_OPTIONS="$INPUT_OPTIONS -draw_mouse 0"
fi

retcode=1
max_attempts=300
attempts=0
Expand All @@ -27,4 +28,15 @@ until [ $retcode -eq 0 -o $attempts -eq $max_attempts ]; do
fi
attempts=$((attempts+1))
done
exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} ${INPUT_OPTIONS} -i ${BROWSER_CONTAINER_NAME}:${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/data/$FILE_NAME"

mkdir -p ~/.config/pulse

echo -n 'gIvST5iz2S0J1+JlXC1lD3HWvg61vDTV1xbmiGxZnjB6E3psXsjWUVQS4SRrch6rygQgtpw7qmghDFTaekt8qWiCjGvB0LNzQbvhfs1SFYDMakmIXuoqYoWFqTJ+GOXYByxpgCMylMKwpOoANEDePUCj36nwGaJNTNSjL8WBv+Bf3rJXqWnJ/43a0hUhmBBt28Dhiz6Yqowa83Y4iDRNJbxih6rB1vRNDKqRr/J9XJV+dOlM0dI+K6Vf5Ag+2LGZ3rc5sPVqgHgKK0mcNcsn+yCmO+XLQHD1K+QgL8RITs7nNeF1ikYPVgEYnc0CGzHTMvFR7JLgwL2gTXulCdwPbg=='| base64 -d>~/.config/pulse/cookie

export PULSE_SERVER=${BROWSER_CONTAINER_NAME}

if pactl info >/dev/null 2>&1; then
exec ffmpeg -f pulse -i default -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} ${INPUT_OPTIONS} -i ${BROWSER_CONTAINER_NAME}:${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/data/$FILE_NAME"
else
exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} ${INPUT_OPTIONS} -i ${BROWSER_CONTAINER_NAME}:${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/data/$FILE_NAME"
fi
23 changes: 9 additions & 14 deletions static/chrome/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ if [ -n "$VERBOSE" ]; then
DRIVER_ARGS="--verbose"
fi

ROOT_CA_PATH=${ROOT_CA_PATH:-""}
if [ -r "$ROOT_CA_PATH" ]; then
ROOT_CA=$(<"$ROOT_CA_PATH")
ROOT_CA_NAME=$(basename "$ROOT_CA_PATH" | sed -e 's|.crt||g')
fi

ROOT_CA=${ROOT_CA:-""}
if [ -n "$ROOT_CA" ]; then
ROOT_CA_NAME=${ROOT_CA_NAME:-"UserRootCA"}
mkdir -p ~/.pki/nssdb
certutil -d "sql:$HOME/.pki/nssdb" -N --empty-password
echo "$ROOT_CA" | certutil -d "sql:$HOME/.pki/nssdb" -A -t TC -n "$ROOT_CA_NAME"
fi

clean() {
if [ -n "$FILESERVER_PID" ]; then
kill -TERM "$FILESERVER_PID"
Expand All @@ -43,6 +29,9 @@ clean() {
if [ -n "$DEVTOOLS_PID" ]; then
kill -TERM "$DEVTOOLS_PID"
fi
if [ -n "$PULSE_PID" ]; then
kill -TERM "$PULSE_PID"
fi
}

trap clean SIGINT SIGTERM
Expand All @@ -58,6 +47,12 @@ XSELD_PID=$!

while ip addr | grep inet | grep -q tentative > /dev/null; do sleep 0.1; done

mkdir -p ~/.config/pulse
echo -n 'gIvST5iz2S0J1+JlXC1lD3HWvg61vDTV1xbmiGxZnjB6E3psXsjWUVQS4SRrch6rygQgtpw7qmghDFTaekt8qWiCjGvB0LNzQbvhfs1SFYDMakmIXuoqYoWFqTJ+GOXYByxpgCMylMKwpOoANEDePUCj36nwGaJNTNSjL8WBv+Bf3rJXqWnJ/43a0hUhmBBt28Dhiz6Yqowa83Y4iDRNJbxih6rB1vRNDKqRr/J9XJV+dOlM0dI+K6Vf5Ag+2LGZ3rc5sPVqgHgKK0mcNcsn+yCmO+XLQHD1K+QgL8RITs7nNeF1ikYPVgEYnc0CGzHTMvFR7JLgwL2gTXulCdwPbg=='| base64 -d>~/.config/pulse/cookie
pulseaudio --start --exit-idle-time=-1
pactl load-module module-native-protocol-tcp
PULSE_PID=$(ps --no-headers -C pulseaudio -o pid)

/usr/bin/xvfb-run -l -n "$DISPLAY_NUM" -s "-ac -screen 0 $SCREEN_RESOLUTION -noreset -listen tcp" /usr/bin/fluxbox -display "$DISPLAY" -log /dev/null 2>/dev/null &
XVFB_PID=$!

Expand Down
9 changes: 9 additions & 0 deletions static/firefox/selenoid/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ clean() {
if [ -n "$X11VNC_PID" ]; then
kill -TERM "$X11VNC_PID"
fi
if [ -n "$PULSE_PID" ]; then
kill -TERM "$PULSE_PID"
fi
}

trap clean SIGINT SIGTERM
Expand All @@ -37,6 +40,12 @@ FILESERVER_PID=$!
DISPLAY="$DISPLAY" /usr/bin/xseld &
XSELD_PID=$!

mkdir -p ~/.config/pulse
echo -n 'gIvST5iz2S0J1+JlXC1lD3HWvg61vDTV1xbmiGxZnjB6E3psXsjWUVQS4SRrch6rygQgtpw7qmghDFTaekt8qWiCjGvB0LNzQbvhfs1SFYDMakmIXuoqYoWFqTJ+GOXYByxpgCMylMKwpOoANEDePUCj36nwGaJNTNSjL8WBv+Bf3rJXqWnJ/43a0hUhmBBt28Dhiz6Yqowa83Y4iDRNJbxih6rB1vRNDKqRr/J9XJV+dOlM0dI+K6Vf5Ag+2LGZ3rc5sPVqgHgKK0mcNcsn+yCmO+XLQHD1K+QgL8RITs7nNeF1ikYPVgEYnc0CGzHTMvFR7JLgwL2gTXulCdwPbg=='| base64 -d>~/.config/pulse/cookie
pulseaudio --start --exit-idle-time=-1
pactl load-module module-native-protocol-tcp
PULSE_PID=$(ps --no-headers -C pulseaudio -o pid)

/usr/bin/xvfb-run -l -n "$DISPLAY_NUM" -s "-ac -screen 0 $SCREEN_RESOLUTION -noreset -listen tcp" /usr/bin/fluxbox -display "$DISPLAY" -log /dev/null 2>/dev/null &
XVFB_PID=$!

Expand Down

0 comments on commit 4e9270d

Please sign in to comment.