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

Blank Videos in Docker #16

Open
zfoborden opened this issue Apr 25, 2017 · 2 comments
Open

Blank Videos in Docker #16

zfoborden opened this issue Apr 25, 2017 · 2 comments

Comments

@zfoborden
Copy link

zfoborden commented Apr 25, 2017

I am attempting to record a suite of protractor tests. The suite runs on (and behaves the same on) both local dev machines (Macbooks) and Jenkins CI. We use Docker containers to run the tests. In the container running the tests I start Xvfb with & to run it in the background These are my settings.

const videoReporter = new VideoReporter({
  baseDirectory: './reports/videos',
  singleVideo: false,
  //saveSuccessVideos: true,
  ffmpegArgs: [
    '-y',
    '-r', '30',
    '-f', 'x11grab',
    '-s', '1024x768',
    '-i', ':0.0',
    '-g', '300',
    '-vcodec', 'mpeg4',
    '-probesize', '10M'
  ]
});

The video files are created and they have the proper subtitles but the video is just black with an 'X' in the middle of the screen. I'm starting Xvfb like this Xvfb :0 -screen 1024x768x24. I turned on the debugger and this is the output I got, this is what the debugger prints to the console up until the point it starts iterating over the specs.

Spec started
  protractor-video-reporter Saving video to reports/videos/6da59467-a489-44d7-9506-08019a5882be.mov +0ms
  protractor-video-reporter Spawning: ffmpeg -y -r 30 -f x11grab -s 1024x768 -i :0.0 -g 300 -vcodec mpeg4 -probesize 10M reports/videos/6da59467-a489-44d7-9506-08019a5882be.mov +6ms
  protractor-video-reporter ffmpeg (err): ffmpeg version git-2017-01-22-f1214ad +1s
  protractor-video-reporter ffmpeg (err):  Copyright (c) 2000-2017 the FFmpeg developers +3ms
  protractor-video-reporter ffmpeg (err): 
 +2ms
  protractor-video-reporter ffmpeg (err):   built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
 +2ms
  protractor-video-reporter ffmpeg (err):   configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
 +2ms
  protractor-video-reporter ffmpeg (err):   libavutil      55. 44.100 / 55. 44.100
 +7ms
  protractor-video-reporter ffmpeg (err):   libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 63.100 / 57. 63.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 69.100 /  6. 69.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
 +3ms
  protractor-video-reporter ffmpeg (err): [x11grab @ 0x30a3780]  +167ms
  protractor-video-reporter ffmpeg (err): Stream #0: not enough frames to estimate rate; consider increasing probesize
 +4ms
  protractor-video-reporter ffmpeg (err): Input #0, x11grab, from ':0.0':
 +23ms
  protractor-video-reporter ffmpeg (err):   Duration:  +2ms
  protractor-video-reporter ffmpeg (err): N/A +2ms
  protractor-video-reporter ffmpeg (err): , start:  +1ms
  protractor-video-reporter ffmpeg (err): 1493147754.409146 +1ms
  protractor-video-reporter ffmpeg (err): , bitrate: N/A
 +7ms
  protractor-video-reporter ffmpeg (err):     Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1024x768, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc
 +5ms
  protractor-video-reporter ffmpeg (err): Output #0, mov, to 'reports/videos/6da59467-a489-44d7-9506-08019a5882be.mov':
 +90ms
  protractor-video-reporter ffmpeg (err):   Metadata:
 +1ms
  protractor-video-reporter ffmpeg (err):     encoder         :  +1ms
  protractor-video-reporter ffmpeg (err): Lavf57.63.100 +1ms
  protractor-video-reporter ffmpeg (err): 
 +0ms
  protractor-video-reporter ffmpeg (err):     Stream #0:0 +1ms
  protractor-video-reporter ffmpeg (err): : Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1024x768, q=2-31, 200 kb/s +1ms
  protractor-video-reporter ffmpeg (err): ,  +0ms
  protractor-video-reporter ffmpeg (err): 30 fps,  +0ms
  protractor-video-reporter ffmpeg (err): 15360 tbn,  +1ms
  protractor-video-reporter ffmpeg (err): 30 tbc +1ms
  protractor-video-reporter ffmpeg (err): 
 +0ms
  protractor-video-reporter ffmpeg (err):     Metadata:
 +0ms
  protractor-video-reporter ffmpeg (err):       encoder         :  +1ms
  protractor-video-reporter ffmpeg (err): Lavc57.75.100 mpeg4 +1ms
  protractor-video-reporter ffmpeg (err): 
 +0ms
  protractor-video-reporter ffmpeg (err):     Side data:
 +0ms
  protractor-video-reporter ffmpeg (err):       cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help

It's doesn't seem to matter what I set the codec to be. mpeg4 has the same behavior as qtrle except mpeg4 produces larger file sizes. I'm certain X11 is running as I can see the /tmp/.X11-unix file as well as /tmp/.X0-lock. I know the process is running and it seems to be connecting as well since the video file's dimensions will change in response to running protractor-video-reporter with different screen resolution settings.

I'm pretty much fresh out of ideas at this point. Any help would be greatly appreciated.

@zfoborden
Copy link
Author

zfoborden commented May 4, 2017

For anyone concerned.

The issue was that X11 and Xvfb needed to be running in the Selenium container. The solution we ended up going with was building our own docker container based off of SeleniumHQ's StandaloneChrome.

Dockerfile:

FROM selenium/standalone-chrome:3.4.0-bismuth

USER root

COPY entry-point.sh /entry-point.sh

ENTRYPOINT ["/entry-point.sh"]

Then we rolled our own entry-point.sh file which looks like this:

#!/bin/bash

source /opt/bin/functions.sh

if [ -z "$GEOMETRY" ]; then
	GEOMETRY="1360x1020x24"
fi
echo "screen geometry set to: ${GEOMETRY}"


function shutdown {
  kill -s SIGTERM $NODE_PID
  wait $NODE_PID
}

if [ ! -z "$SE_OPTS" ]; then
  echo "appending selenium options: ${SE_OPTS}"
fi

SERVERNUM=$(get_server_num)

rm -f /tmp/.X*lock

Xvfb :99 -screen 0 ${GEOMETRY} -ac -listen tcp &
sleep 10
NODE_PID=$!
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
  ${SE_OPTS} &
NODE_PID=$!

trap shutdown SIGTERM SIGINT
wait $NODE_PID

Hope this will help anyone who comes along trying to do something similar.

@eugene-petrash
Copy link

eugene-petrash commented Oct 28, 2017

@zfoborden All that you need to do it is specify <container ip>:<display in container> , like this

ffmpegArgs: [
    '-y',
    '-r', '30',
    '-f', 'x11grab',
    '-s', '1280x3000',
    '-i', '192.168.125.11:99',
    '-g', '300',
    '-vcodec', 'qtrle'
],

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants