From dfc0006b3b53942879724dd0cf06449f3caab8da Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 4 Sep 2020 02:18:36 -0700 Subject: [PATCH] devops: bundle ffmpeg with chromium (#3767) This starts bundling FFMPEG v4.3.1 binary with Chromium archives on the following platforms: - chromium-mac - chromium-win32 - chromium-win64 This specifically doesn't bundle FFMPEG with chromium-linux since we decided to use native ffmpeg on Linux instead. FFMPEG binaries are compiled following these instructions: - windows: https://gist.github.com/aslushnikov/422f1e1a57796a476bf73ebe04f2e5ac - mac: https://gist.github.com/aslushnikov/abf71be5a0b12c33b320044785fcb3bc Our versions of FFMPEG are ~2MB zipped. References #3680 --- browser_patches/chromium/BUILD_NUMBER | 2 +- browser_patches/chromium/build.sh | 57 +++++++++++++++++---------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/browser_patches/chromium/BUILD_NUMBER b/browser_patches/chromium/BUILD_NUMBER index fc076b6c45..5c111e426a 100644 --- a/browser_patches/chromium/BUILD_NUMBER +++ b/browser_patches/chromium/BUILD_NUMBER @@ -1 +1 @@ -799610 +792639 diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.sh index 521e2d8ab5..3285a65108 100755 --- a/browser_patches/chromium/build.sh +++ b/browser_patches/chromium/build.sh @@ -5,40 +5,57 @@ set +x trap "cd $(pwd -P)" EXIT cd "$(dirname $0)" +rm -rf output mkdir -p output cd output BUILD_NUMBER=$(head -1 ../BUILD_NUMBER) -FOLDER_NAME="" -ZIP_NAME="" -FILES_TO_REMOVE=() + +CHROMIUM_URL="" +CHROMIUM_FOLDER_NAME="" +CHROMIUM_FILES_TO_REMOVE=() + +FFMPEG_VERSION="4.3.1" +FFMPEG_URL="" +FFMPEG_BIN_PATH="" if [[ $1 == "--win32" ]]; then - FOLDER_NAME="Win" - ZIP_NAME="chrome-win.zip" - FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") + CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Win/${BUILD_NUMBER}/chrome-win.zip" + CHROMIUM_FOLDER_NAME="chrome-win" + CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") + FFMPEG_URL="https://playwright2.blob.core.windows.net/builds/ffmpeg/${FFMPEG_VERSION}/ffmpeg-win32.zip" + FFMPEG_BIN_PATH="ffmpeg.exe" elif [[ $1 == "--win64" ]]; then - FOLDER_NAME="Win_x64" - ZIP_NAME="chrome-win.zip" - FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") + CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/${BUILD_NUMBER}/chrome-win.zip" + CHROMIUM_FOLDER_NAME="chrome-win" + CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") + FFMPEG_URL="https://playwright2.blob.core.windows.net/builds/ffmpeg/${FFMPEG_VERSION}/ffmpeg-win64.zip" + FFMPEG_BIN_PATH="ffmpeg.exe" elif [[ $1 == "--mac" ]]; then - FOLDER_NAME="Mac" - ZIP_NAME="chrome-mac.zip" + CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Mac/${BUILD_NUMBER}/chrome-mac.zip" + CHROMIUM_FOLDER_NAME="chrome-mac" + FFMPEG_URL="https://playwright2.blob.core.windows.net/builds/ffmpeg/${FFMPEG_VERSION}/ffmpeg-mac.zip" + FFMPEG_BIN_PATH="ffmpeg" elif [[ $1 == "--linux" ]]; then - FOLDER_NAME="Linux_x64" - ZIP_NAME="chrome-linux.zip" + CHROMIUM_URL="https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${BUILD_NUMBER}/chrome-linux.zip" + CHROMIUM_FOLDER_NAME="chrome-linux" + # Even though we could bundle ffmpeg on Linux (2.5MB zipped), we + # prefer rely on system-installed ffmpeg instead. else echo "ERROR: unknown platform to build: $1" exit 1 fi -URL="https://storage.googleapis.com/chromium-browser-snapshots/${FOLDER_NAME}/${BUILD_NUMBER}/${ZIP_NAME}" -curl --output upstream.zip "${URL}" - -unzip upstream.zip - -for file in ${FILES_TO_REMOVE[@]}; do +curl --output chromium-upstream.zip "${CHROMIUM_URL}" +unzip chromium-upstream.zip +for file in ${CHROMIUM_FILES_TO_REMOVE[@]}; do rm -f "${file}" done -zip --symlinks -r build.zip ${ZIP_NAME%.zip} +if [[ -n "${FFMPEG_URL}" ]]; then + curl --output ffmpeg-upstream.zip "${FFMPEG_URL}" + unzip ffmpeg-upstream.zip + cp "$FFMPEG_BIN_PATH" "${CHROMIUM_FOLDER_NAME}" +fi + +zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}"