Closed arman-sydikov closed 5 years ago
I modified /usr/bin/start-video
$ docker exec grid sudo sed -i 's/export VIDEO_FILE_NAME=.*/export VIDEO_FILE_NAME="test"/g' /usr/bin/start-video
$ docker exec grid cat /usr/bin/start-video
#!/usr/bin/env bash
echoerr() { printf "%s\n" "$*" >&2; }
# print error and exit
die () {
echoerr "ERROR: $1"
# if $2 is defined AND NOT EMPTY, use $2; otherwise, set to "150"
errnum=${2-150}
exit $errnum
}
[ -z "${VIDEO_REC_STOP_SIGNAL}" ] && export VIDEO_REC_STOP_SIGNAL="INT"
[ -z "${LOGFILE_MAXBYTES}" ] && export LOGFILE_MAXBYTES="10MB"
[ -z "${LOGFILE_BACKUPS}" ] && export LOGFILE_BACKUPS=5
[ -z "${LOGS_DIR}" ] && export LOGS_DIR="/var/log/cont"
export VIDEO_LOG_FILE="$(cat VIDEO_LOG_FILE)"
export VIDEO_PIDFILE="$(cat VIDEO_PIDFILE)"
export VIDEO_FILE_NAME="test"
export VIDEO_PATH="$(cat VIDEO_PATH)"
# Test: supervisorctl -c /etc/supervisor/supervisord.conf status
export VIDEO=true
supervisorctl -c /etc/supervisor/supervisord.conf start video-rec
timeout --foreground ${WAIT_TIMEOUT} wait-video-rec.sh || \
die "Failed while waiting for video recording to start!"
I started video record again :
$ docker exec grid start-video
video-rec: started
Waiting for ffmpeg video recording to start...
.Videos at /home/seluser/videos/vid_chrome_24402.mp4* started to be recorded! (wait-video-rec.sh)
still recording video to the file with the default file name vid_chrome_24402.mp4
From start-video-rec.sh
we can see that ffmpeg records a video into ${tmp_video_path}
file :
export tmp_video_path="${VIDEOS_DIR}/${VIDEO_FILE_NAME}.${VIDEO_TMP_FILE_EXTENSION}"
export final_video_path="${VIDEOS_DIR}/${VIDEO_FILE_NAME}.${VIDEO_FILE_EXTENSION}"
ffmpeg -f x11grab \
-s ${FFMPEG_FRAME_SIZE} \
-draw_mouse ${FFMPEG_DRAW_MOUSE} \
-i "${DISPLAY}.0" \
${FFMPEG_CODEC_ARGS} \
-r ${FFMPEG_FRAME_RATE} \
-y -an "${tmp_video_path}" 2>&1 &
Adding export VIDEO_FILE_NAME=filename
did the trick :
$ docker exec grid sudo sed -i '5s/.*/export VIDEO_FILE_NAME=filename/' /usr/bin/start-video-rec.sh
The README mentions how to do it
https://github.com/elgalu/docker-selenium#record-videos, VIDEO_FILE_NAME
needs to be passed as an env var.
@diemol it works only when starting a new container, but my question was about changing video file name on already started container : https://github.com/elgalu/docker-selenium/blob/master/docs/videos.md#start
For example the following code does not change the file name :
$ docker exec grid -e VIDEO_FILE_NAME=filename start-video
video-rec: started
Waiting for ffmpeg video recording to start...
Videos at /home/seluser/videos/vid_chrome_27390.mkv* started to be recorded! (wait-video-rec.sh)
Ah ok, got it. No, this is only supported for the use case when the container is started.
How to set VIDEO_FILE_NAME when starting video record manually ?
What I did
As I understand
/usr/bin/start-video
gets the file name fromcat VIDEO_FILE_NAME
:I executed
cat VIDEO_FILE_NAME
and it printed the default file name :I changed the default file name :
I started video record manually :
but it still recording video to the file with the default file name
vid_chrome_24402.mp4
Operating System
Linux GDais00016 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Image version
3.141.59-p13
Docker version
Docker version 18.09.1, build 4c52b90