Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 2941193

Browse files
committed
Add VIDEO_BEFORE_STOP_SLEEP_SECS and VIDEO_AFTER_STOP_SLEEP_SECS
1 parent b52c556 commit 2941193

File tree

11 files changed

+97
-37
lines changed

11 files changed

+97
-37
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@ Note image ids also change after scm-source.json has being updated which trigger
77
###### To get container versions
88
docker exec grid versions
99

10+
## TBD_DOCKER_TAG
11+
+ Date: TBD_DATE
12+
+ Split VIDEO_STOP_SLEEP_SECS="1" into
13+
+ VIDEO_BEFORE_STOP_SLEEP_SECS and
14+
+ VIDEO_AFTER_STOP_SLEEP_SECS
15+
+ Drop VIDEO_CHUNKS_MAX=999 as it is buggy
16+
+ Image tag details:
17+
+ Selenium 2: TBD_SELENIUM_2_VERSION (TBD_SELENIUM_2_REVISION)
18+
+ Selenium 3: 3.1.0 (86a5d70)
19+
+ Chrome stable: TBD_CHROME_STABLE
20+
+ Firefox for Selenium 2: TBD_FIREFOX_FOR_SEL2
21+
+ Firefox for Selenium 3: TBD_FIREFOX_FOR_SEL3
22+
+ Geckodriver: TBD_GECKO_DRIVER
23+
+ Chromedriver: TBD_CHROME_DRIVER (TBD_CHROMEDRIVER_COMMIT)
24+
+ Java: TBD_JAVA_VENDOR Java TBD_JAVA_BUILD
25+
+ Timezone: TBD_TIME_ZONE
26+
+ FROM ubuntu:UBUNTU_FLAVOR-UBUNTU_DATE
27+
+ Python: TBD_PYTHON_VERSION
28+
+ Tested on kernel dev host: 4.4.0-64-generic x86_64
29+
+ Tested on kernel CI host: TBD_HOST_UNAME
30+
+ Built at dev host with: Docker version 1.13.1, build 092cba3
31+
+ Built at CI host with: Docker version TBD_DOCKER_VERS, build TBD_DOCKER_BUILD
32+
+ Built at dev host with: Docker Compose version 1.11.2, build dfed245
33+
+ Built at CI host with: Docker Compose version TBD_DOCKER_COMPOSE_VERS, build TBD_DOCKER_COMPOSE_BUILD
34+
+ Image size: TBD_IMAGE_SIZE
35+
+ Digest: TBD_DIGEST
36+
+ Image ID: TBD_IMAGE_ID
37+
1038
## 3.1.0-p1
1139
+ Date: 2017-02-27
1240
+ Re-enable VIDEO_STOP_SLEEP_SECS="1" for 1 sec video fix

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Local
44
For pull requests or local commits:
55

6-
time (./test/bef && ./test/install && ./test/script_start && ./test/script_end) ; beep
6+
time (./test/bef && ./test/install && ./test/script_start && ./test/script_end)
77
docker exec grid versions && ./test/after_script && travis lint
88
open ./images/grid2_console.png && open ./images/grid3_console.png && open ./videos/mobile_emulation/*.mp4
99
git checkout ./images/grid2_console.png && git checkout ./images/grid3_console.png
@@ -12,7 +12,7 @@ For pull requests or local commits:
1212

1313
For repository owners only:
1414

15-
git commit -m "Re-enable VIDEO_STOP_SLEEP_SECS="1" for 1 sec video fix"
15+
git commit -m "Add VIDEO_BEFORE_STOP_SLEEP_SECS and VIDEO_AFTER_STOP_SLEEP_SECS"
1616
git tag -d latest && git tag `cat VERSION` && git push origin tmp-`cat VERSION` && git push --tags
1717

1818
-- Wait for Travis to pass OK

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ RUN apt-get -qqy update \
443443
# ffmpeg/libav/avconv video codecs & dependencies
444444
#=================================================
445445
# MP4Box (gpac) to clean the video credits to @taskworld @dtinth
446+
# ponchio/untrunc dependencies to restore a damaged (truncated) video
447+
# libavformat-dev libavcodec-dev libavutil-dev libqt4-dev make g++ libz-dev
446448
# Layer size: medium: 11.56 MB (with --no-install-recommends)
447449
# Layer size: medium: 20.76 MB
448450
RUN apt-get -qqy update \
@@ -860,11 +862,11 @@ ENV FIREFOX_VERSION="${FF_VER}" \
860862
RC_CHROME="false" \
861863
RC_FIREFOX="false" \
862864
VIDEO_FILE_EXTENSION="mp4" \
863-
MP4_INTERLEAVES_MEDIA_DATA_CHUNKS_SECS="500" \
865+
MP4_INTERLEAVES_MEDIA_DATA_CHUNKS_SECS="50" \
864866
VIDEO_FILE_NAME="" \
865-
VIDEO_CHUNK_SECS="00:05:00" \
866-
VIDEO_CHUNKS_MAX=999 \
867-
VIDEO_STOP_SLEEP_SECS="1" \
867+
VIDEO_CHUNK_SECS="00:15:00" \
868+
VIDEO_BEFORE_STOP_SLEEP_SECS="1" \
869+
VIDEO_AFTER_STOP_SLEEP_SECS="0.5" \
868870
WAIT_TIME_OUT_VIDEO_STOP="20s" \
869871
VIDEOS_DIR="/home/seluser/videos" \
870872
XMANAGER="fluxbox" \
@@ -882,6 +884,7 @@ ENV FIREFOX_VERSION="${FF_VER}" \
882884
VNC_STOP_SIGNAL="TERM" \
883885
NOVNC_STOP_SIGNAL="TERM" \
884886
VIDEO_REC_STOP_SIGNAL="INT" \
887+
VIDEO_STOPWAITSECS=20 \
885888
DOCKER_SOCK="/var/run/docker.sock" \
886889
TEST_SLEEPS="0.5" \
887890
SEND_ANONYMOUS_USAGE_INFO="true" \

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.0-p1
1+
3.1.0-p2

bin/untrunc

194 KB
Binary file not shown.

misc/misc.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,22 @@ If you also want windows manager support, i.e. want to `make move` _(optional bu
444444
cd binaries && wget -O stable_updates.html "http://googlechromereleases.blogspot.de/search/label/Stable%20updates"
445445
VER=$(grep -Po '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' stable_updates.html | head -1)
446446
rm -f stable_updates.html && cd ..
447+
448+
### videos
449+
450+
##################################################
451+
# untrunc to restore a damaged (truncated) video #
452+
##################################################
453+
# Download ponchio/untrunc dated 2015-09-08 commit 07be275f02927417e81da7d3729a3854b9d98b37
454+
ENV UNTRUNC_SHA="07be275f02927417e81da7d3729a3854b9d98b37"
455+
RUN wget -nv -O unTrunc.zip \
456+
"https://github.com/ponchio/untrunc/archive/${UNTRUNC_SHA}.zip" \
457+
&& unzip -x unTrunc.zip \
458+
&& mv untrunc-${UNTRUNC_SHA} untrunc \
459+
&& rm unTrunc.zip \
460+
&& cd untrunc \
461+
&& g++ -o untrunc file.cpp main.cpp \
462+
track.cpp atom.cpp mp4.cpp \
463+
-L/usr/local/lib -lavformat \
464+
-lavcodec -lavutil \
465+
&& mv untrunc /usr/bin

video-rec/bin/ffmpeg-start-sh

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,22 @@ trap shutdown SIGTERM SIGINT SIGKILL
3131
# https://www.ffmpeg.org/ffmpeg-codecs.html
3232
# sudo avconv -an -y -f x11grab \
3333

34-
for i in $(seq -f "%03g" 0 ${VIDEO_CHUNKS_MAX}); do
35-
video_name="${VIDEO_FILE_NAME}-$i"
36-
if [ "$i" == "000" ]; then
37-
video_name="${VIDEO_FILE_NAME}"
38-
fi
39-
video_path="${VIDEOS_DIR}/${video_name}.${VIDEO_FILE_EXTENSION}"
40-
41-
# Fix perms to be able to start ffmpeg without sudo
42-
sudo touch "${video_path}"
43-
sudo chown seluser:seluser "${video_path}"
44-
45-
# avconv or ffmpeg
46-
avconv -f x11grab \
47-
-framerate ${FFMPEG_FRAME_RATE} \
48-
-video_size ${FFMPEG_FRAME_SIZE} \
49-
-i "${DISPLAY}.0+0,0" \
50-
${FFMPEG_CODEC_ARGS} \
51-
-t "${VIDEO_CHUNK_SECS}" \
52-
-segment_format_options movflags=+faststart \
53-
-y -an "${video_path}" 2>&1 &
54-
LAST_FFMPEG_PID=$!
55-
56-
# tells bash to wait until child processes have exited
57-
wait
58-
done
34+
video_path="${VIDEOS_DIR}/${VIDEO_FILE_NAME}.${VIDEO_FILE_EXTENSION}"
35+
36+
# Fix perms to be able to start ffmpeg without sudo
37+
sudo touch "${video_path}"
38+
sudo chown seluser:seluser "${video_path}"
39+
40+
# avconv or ffmpeg
41+
avconv -f x11grab \
42+
-framerate ${FFMPEG_FRAME_RATE} \
43+
-video_size ${FFMPEG_FRAME_SIZE} \
44+
-i "${DISPLAY}.0+0,0" \
45+
${FFMPEG_CODEC_ARGS} \
46+
-t "${VIDEO_CHUNK_SECS}" \
47+
-segment_format_options movflags=+faststart \
48+
-y -an "${video_path}" 2>&1 &
49+
LAST_FFMPEG_PID=$!
50+
51+
# tells bash to wait until child processes have exited
52+
wait

video-rec/bin/fix_videos.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -e
55

66
# Optimize for HTTP streaming and fix end time
77
for f in *.mp4; do
8+
# ponchio/untrunc is used to restore a damaged (truncated) video
9+
# untrunc /home/seluser/working_video.mp4 ${f}
10+
811
echo "Optimizing ${f} for HTTP streaming..."
912
# -inter Duration : interleaves media data in chunks of desired
1013
# duration (in seconds). This is useful to optimize the file for

video-rec/bin/start-video-rec.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ VID_TOOL_PID=$!
2222
# sudo killall -SIGINT avconv
2323
function shutdown {
2424
echo "Trapped SIGTERM or SIGINT so shutting down ffmpeg gracefully..."
25-
sleep ${VIDEO_STOP_SLEEP_SECS}
26-
kill -SIGTERM ${VID_TOOL_PID} || true
27-
sleep ${VIDEO_STOP_SLEEP_SECS}
25+
kill -SIGINT ${VID_TOOL_PID} || true
2826
wait ${VID_TOOL_PID}
2927
fix_videos.sh
3028
echo "ffmpeg shutdown complete."

video-rec/bin/stop-video

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ fi
2525
# Stop video recording
2626
#----------------------
2727
export VIDEO=false
28-
sleep ${VIDEO_STOP_SLEEP_SECS}
28+
sleep ${VIDEO_BEFORE_STOP_SLEEP_SECS}
2929
supervisorctl -c /etc/supervisor/supervisord.conf stop video-rec
30-
sleep ${VIDEO_STOP_SLEEP_SECS}
30+
sleep ${VIDEO_AFTER_STOP_SLEEP_SECS}
3131

3232
# Avoid waiting forever using the `timeout` command
3333
if timeout --foreground ${WAIT_TIME_OUT_VIDEO_STOP} \

0 commit comments

Comments
 (0)