Skip to content

Commit

Permalink
tweak video recording and emulator version #639
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
thoutbeckers committed Mar 27, 2023
1 parent 00a9315 commit 2819c20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
43 changes: 31 additions & 12 deletions .github/workflows/emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd.v5-${{ matrix.api-level }}
key: avd.v8-${{ matrix.api-level }}

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
Expand All @@ -65,42 +65,61 @@ jobs:
ram-size: 3G
heap-size: 1500M
profile: 3.4in WQVGA
channel: canary
script: echo "Generated AVD snapshot for caching."

- name: run ffmpeg screen capture
- name: install ffmpeg
if: inputs.video
run: |
brew install ffmpeg
ffmpeg -nostdin -f avfoundation -i 0 recording-${{ matrix.project }}-${{ matrix.api-level }}.mov &
sleep 5
uses: FedericoCarboni/setup-ffmpeg@v2

- name: pregenerate test package
if: inputs.video
run: ./gradlew --no-configuration-cache :${{ matrix.project }}:packageDebugAndroidTest

# - name: run ffmpeg screen capture
# if: inputs.video
# run: |
# ./record_emulator.sh recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4 &
# sleep 5

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot-save -noaudio -no-boot-anim -camera-back none
disable-animations: true
arch: x86_64
disk-size: 3G
ram-size: 3G
heap-size: 1500M
profile: 3.4in WQVGA
script: ./gradlew :${{ matrix.project }}:connectedDebugAndroidTest
channel: canary
script: ./gradlew --no-configuration-cache :${{ matrix.project }}:recordVideo :${{ matrix.project }}:connectedDebugAndroidTest

- name: stop screen capture
if: inputs.video
if: always() && inputs.video
continue-on-error: true
shell: bash
run: |
ps aux | grep -m 1 ffmpeg
ps aux | grep -m 1 screenrecord
PID=$(ps aux | grep -m 1 ffmpeg | awk '{print $2}')
python -c "import os, signal; os.kill($PID, signal.SIGINT)"
sleep 2
PID=$(ps aux | grep -m 1 screenrecord | awk '{print $2}')
python -c "import os, signal; os.kill($PID, signal.SIGINT)"
sleep 5
mv video.mp4 recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4
- name: upload video
if: inputs.video
if: always() && inputs.video
continue-on-error: true
uses: actions/upload-artifact@master
with:
name: Recording-${{ matrix.project }}-${{ matrix.api-level }}
path: recording-${{ matrix.project }}-${{ matrix.api-level }}.mov
name: recording-${{ matrix.project }}-${{ matrix.api-level }}
path: recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4
8 changes: 8 additions & 0 deletions date-time-picker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
id("org.jetbrains.dokka")
id("org.jlleitschuh.gradle.ktlint")
id("com.github.psxpaul.execfork") version "0.2.2"
}

publishableComponent()
Expand All @@ -13,6 +14,13 @@ dependencies {
androidTestImplementationDependency(Dependencies.AndroidX.Activity.Ktx)
}

task<com.github.psxpaul.task.ExecFork>("recordVideo") {
executable = "./record_emulator.sh"
args.add("video.mp4")
workingDir = project.rootProject.rootDir
waitForOutput = "FFmpeg developers"
}

kotlin {
sourceSets {
getByName("commonMain") {
Expand Down
4 changes: 4 additions & 0 deletions record_emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -x
echo "Record to $1"
adb shell "while true; do screenrecord --output-format=h264 -; done" | ffmpeg -i - $1

0 comments on commit 2819c20

Please sign in to comment.