Skip to content

Commit

Permalink
Update FFmpeg 7.0.1 (#2287)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 authored Jun 24, 2024
1 parent 9acf128 commit 0424655
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
deploy:
needs:
- build-test
if: contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true' && !failure() && !cancelled())
if: (contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && !failure() && !cancelled()
name: Deploy Docker images
runs-on: ubuntu-latest
permissions: write-all
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
deploy:
needs:
- build-test
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && !failure() && !cancelled())
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && !failure() && !cancelled()
name: Nightly build
runs-on: ubuntu-latest
permissions: write-all
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ BUILD_ARGS := $(BUILD_ARGS)
MAJOR := $(word 1,$(subst ., ,$(TAG_VERSION)))
MINOR := $(word 2,$(subst ., ,$(TAG_VERSION)))
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(TAG_VERSION)))
FFMPEG_TAG_VERSION := $(or $(FFMPEG_TAG_VERSION),$(FFMPEG_TAG_VERSION),ffmpeg-6.1.1)
FFMPEG_TAG_PREV_VERSION := $(or $(FFMPEG_TAG_PREV_VERSION),$(FFMPEG_TAG_PREV_VERSION),ffmpeg-6.1.1)
FFMPEG_TAG_VERSION := $(or $(FFMPEG_TAG_VERSION),$(FFMPEG_TAG_VERSION),ffmpeg-7.0.1)
FFMPEG_BASED_NAME := $(or $(FFMPEG_BASED_NAME),$(FFMPEG_BASED_NAME),linuxserver)
FFMPEG_BASED_TAG := $(or $(FFMPEG_BASED_TAG),$(FFMPEG_BASED_TAG),version-6.1.1-cli)
FFMPEG_BASED_TAG := $(or $(FFMPEG_BASED_TAG),$(FFMPEG_BASED_TAG),7.0.1)
PLATFORMS := $(or $(PLATFORMS),$(shell echo $$PLATFORMS),linux/amd64)

all: hub \
Expand Down
6 changes: 3 additions & 3 deletions Video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ USER root
# Customize sources for apt-get
#================================================
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
echo "deb http://archive.ubuntu.com/ubuntu jammy main universe\n" > /etc/apt/sources.list \
&& echo "deb http://archive.ubuntu.com/ubuntu jammy-updates main universe\n" >> /etc/apt/sources.list \
&& echo "deb http://security.ubuntu.com/ubuntu jammy-security main universe\n" >> /etc/apt/sources.list ; \
echo "deb http://archive.ubuntu.com/ubuntu noble main universe\n" > /etc/apt/sources.list \
&& echo "deb http://archive.ubuntu.com/ubuntu noble-updates main universe\n" >> /etc/apt/sources.list \
&& echo "deb http://security.ubuntu.com/ubuntu noble-security main universe\n" >> /etc/apt/sources.list ; \
fi

# No interactive frontend during docker build
Expand Down
2 changes: 2 additions & 0 deletions Video/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ SUPERVISOR_PID=$!
function shutdown {
echo "Trapped SIGTERM/SIGINT/x so shutting down supervisord..."
kill -s SIGTERM ${SUPERVISOR_PID}
wait `pgrep -f ffmpeg | tr '\n' ' '`
wait `pgrep -f rclone | tr '\n' ' '`
wait ${SUPERVISOR_PID}
echo "Shutdown complete"
}
Expand Down
26 changes: 20 additions & 6 deletions Video/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,23 @@ function exit_on_max_session_reach() {
fi
}

function stop_ffmpeg() {
while true; do
FFMPEG_PID=$(pgrep -f ffmpeg | tr '\n' ' ')
if [ -n "$FFMPEG_PID" ]; then
kill -SIGTERM $FFMPEG_PID
wait $FFMPEG_PID
fi
if ! pgrep -f ffmpeg > /dev/null; then
break
fi
sleep 0.5
done
}

function stop_recording() {
echo "$(date +%FT%T%Z) [${process_name}] - Stopping to record video"
pkill -INT ffmpeg
stop_ffmpeg
recorded_count=$((recorded_count+1))
recording_started="false"
if [[ "${VIDEO_UPLOAD_ENABLED}" != "false" ]] && [[ -n "${UPLOAD_DESTINATION_PREFIX}" ]];
Expand All @@ -115,7 +129,7 @@ function graceful_exit() {
send_exit_signal_to_uploader
wait_util_uploader_shutdown
rm -rf ${UPLOAD_PIPE_FILE} || true
kill -INT "$(cat /var/run/supervisor/supervisord.pid)"
kill -SIGTERM "$(cat /var/run/supervisor/supervisord.pid)"
}

if [[ "${VIDEO_UPLOAD_ENABLED}" != "true" ]] && [[ "${VIDEO_FILE_NAME}" != "auto" ]] && [[ -n "${VIDEO_FILE_NAME}" ]]; then
Expand All @@ -133,7 +147,7 @@ if [[ "${VIDEO_UPLOAD_ENABLED}" != "true" ]] && [[ "${VIDEO_FILE_NAME}" != "auto
done

# exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal
exec ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 1 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
exec ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
-video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM}.0 -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "$VIDEO_FOLDER/$VIDEO_FILE_NAME"

else
Expand Down Expand Up @@ -167,7 +181,7 @@ else
recorded_count=0

echo "$(date +%FT%T%Z) [${process_name}] - Checking if node API responds"
until curl -sk --request GET ${SE_SERVER_PROTOCOL}://${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT}/status || [[ $attempts = "$max_attempts" ]]
until curl --noproxy "*" -sk --request GET ${SE_SERVER_PROTOCOL}://${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT}/status || [[ $attempts = "$max_attempts" ]]
do
if [ $(($attempts % 60)) -eq 0 ];
then
Expand All @@ -181,7 +195,7 @@ else
echo "$(date +%FT%T%Z) [${process_name}] - Can not reach node API, exiting."
exit
fi
while curl -sk --request GET ${SE_SERVER_PROTOCOL}://${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT}/status > /tmp/status.json
while curl --noproxy "*" -sk --request GET ${SE_SERVER_PROTOCOL}://${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT}/status > /tmp/status.json
do
session_id=$(jq -r '.[]?.node?.slots | .[0]?.session?.sessionId' /tmp/status.json)
if [[ "$session_id" != "null" && "$session_id" != "" && "$recording_started" = "false" ]]
Expand All @@ -199,7 +213,7 @@ else
then
video_file="${VIDEO_FOLDER}/$video_file_name"
echo "$(date +%FT%T%Z) [${process_name}] - Starting to record video"
ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 1 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
exec ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
-video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "$video_file" &
recording_started="true"
echo "$(date +%FT%T%Z) [${process_name}] - Video recording started"
Expand Down
25 changes: 20 additions & 5 deletions Video/video_graphQLQuery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@ if [ -z "${GRAPHQL_ENDPOINT}" ] && [ -n "${SE_NODE_GRID_URL}" ]; then
fi

if [ -n "${GRAPHQL_ENDPOINT}" ]; then
# Send GraphQL query
curl --retry 3 -k -X POST \
-H "Content-Type: application/json" \
--data '{"query":"{ session (id: \"'${SESSION_ID}'\") { id, capabilities, startTime, uri, nodeId, nodeUri, sessionDurationMillis, slot { id, stereotype, lastStarted } } } "}' \
-s "${GRAPHQL_ENDPOINT}" > /tmp/graphQL_${SESSION_ID}.json
while true; do
# Send GraphQL query
curl --noproxy "*" --retry 3 -k -X POST \
-H "Content-Type: application/json" \
--data '{"query":"{ session (id: \"'${SESSION_ID}'\") { id, capabilities, startTime, uri, nodeId, nodeUri, sessionDurationMillis, slot { id, stereotype, lastStarted } } } "}' \
-s "${GRAPHQL_ENDPOINT}" > /tmp/graphQL_${SESSION_ID}.json
# Check if the response contains "capabilities"
if jq -e '.data.session.capabilities' /tmp/graphQL_${SESSION_ID}.json > /dev/null; then
break
else
sleep 0.5
fi
done

# Extract the values from the response
RECORD_VIDEO=$(jq -r '.data.session.capabilities | fromjson | ."'${VIDEO_CAP_NAME}'"' /tmp/graphQL_${SESSION_ID}.json)
TEST_NAME=$(jq -r '.data.session.capabilities | fromjson | ."'${TEST_NAME_CAP}'"' /tmp/graphQL_${SESSION_ID}.json)
VIDEO_NAME=$(jq -r '.data.session.capabilities | fromjson | ."'${VIDEO_NAME_CAP}'"' /tmp/graphQL_${SESSION_ID}.json)
fi

# Check if enabling to record video
if [ "${RECORD_VIDEO,,}" = "false" ]; then
RECORD_VIDEO=false
else
RECORD_VIDEO=true
fi

# Check if video file name is set via capabilities
if [ "${VIDEO_NAME}" != "null" ] && [ -n "${VIDEO_NAME}" ]; then
TEST_NAME="${VIDEO_NAME}"
elif [ "${TEST_NAME}" != "null" ] && [ -n "${TEST_NAME}" ]; then
Expand All @@ -39,13 +50,17 @@ else
TEST_NAME=""
fi

# Check if append session ID to the video file name suffix
if [ -z "${TEST_NAME}" ]; then
TEST_NAME="${SESSION_ID}"
elif [ "${VIDEO_FILE_NAME_SUFFIX,,}" = "true" ]; then
TEST_NAME="${TEST_NAME}_${SESSION_ID}"
fi

# Normalize the video file name
TEST_NAME="$(echo "${TEST_NAME}" | tr ' ' '_' | tr -dc "${VIDEO_FILE_NAME_TRIM}" | cut -c 1-251)"

return_array=("${RECORD_VIDEO}" "${TEST_NAME}")

# stdout the values for other scripts consuming
echo "${return_array[@]}"
2 changes: 1 addition & 1 deletion tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ services:
- BINDING_VERSION=${BINDING_VERSION}
- SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS}
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
command: ["./bootstrap.sh", "${NODE}"]
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]
2 changes: 1 addition & 1 deletion tests/docker-compose-v3-test-node-relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- TEST_NODE_RELAY=${TEST_NODE_RELAY}
- ANDROID_PLATFORM_API=${ANDROID_PLATFORM_API}
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
command: ["./bootstrap.sh", "${NODE}"]
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]

node-relay-emulator:
profiles:
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-v3-test-parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ services:
- TEST_PARALLEL_HARDENING=${TEST_PARALLEL_HARDENING}
- BINDING_VERSION=${BINDING_VERSION}
- TEST_PLATFORMS=${PLATFORMS}
command: ["./bootstrap.sh", "${NODE}"]
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]
2 changes: 1 addition & 1 deletion tests/docker-compose-v3-test-video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ services:
- SELENIUM_GRID_HOST=selenium-hub
- BINDING_VERSION=${BINDING_VERSION}
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
command: ["./bootstrap.sh", "${NODE}"]
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE} && sleep 5"]
4 changes: 4 additions & 0 deletions update_tag_in_docs_and_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ NEXT_TAG=$2
LATEST_DATE=$(echo ${LATEST_TAG} | sed 's/.*-//')
NEXT_DATE=$(echo ${NEXT_TAG} | sed 's/.*-//')
latest_chart_app_version=$(find . \( -type d -name .git -prune \) -o -type f -wholename '*/selenium-grid/Chart.yaml' -print0 | xargs -0 cat | grep ^appVersion | cut -d ':' -f 2 | tr -d '[:space:]')
FFMPEG_TAG_PREV_VERSION=$(grep FFMPEG_TAG_PREV_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
FFMPEG_TAG_VERSION=$(grep FFMPEG_TAG_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
RCLONE_TAG_VERSION=$(grep RCLONE_TAG_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)

echo -e "\033[0;32m Updating tag displayed in docs and files...\033[0m"
echo -e "\033[0;32m LATEST_TAG -> ${LATEST_TAG}\033[0m"
echo -e "\033[0;32m NEXT_TAG -> ${NEXT_TAG}\033[0m"

# If you want to test this locally and you are using macOS, do `brew install gnu-sed` and change `sed` for `gsed`.
find . \( -type d -name .git -prune \) -o -type f ! -name 'CHANGELOG.md' -print0 | xargs -0 sed -i "s/${FFMPEG_TAG_PREV_VERSION}/${FFMPEG_TAG_VERSION}/g"

# If you want to test this locally and you are using macOS, do `brew install gnu-sed` and change `sed` for `gsed`.
find . \( -type d -name .git -prune \) -o -type f ! -name 'CHANGELOG.md' -print0 | xargs -0 sed -i "s/${LATEST_TAG}/${NEXT_TAG}/g"

Expand Down

0 comments on commit 0424655

Please sign in to comment.