Skip to content

Commit

Permalink
try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Sep 1, 2024
1 parent 7be8184 commit 3461767
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,19 @@ jobs:
APPLE_API_KEY_ID: ${{ secrets.api_key_id }}
APPLE_API_ISSUER: ${{ secrets.api_key_issuer_id }}

- run: npx tsx script/e2e.mts 'dist/mac-arm64/LosslessCut.app/Contents/MacOS/LosslessCut' screenshot-macos.jpeg
- run: npx tsx script/e2e.mts 'dist/mac-arm64/LosslessCut.app/Contents/MacOS/LosslessCut' 0:none screenshot-macos.jpeg
if: startsWith(matrix.os, 'macos')

# - run: npx tsx script/e2e.mts 'dist/win-x64/LosslessCut.app/Contents/MacOS/LosslessCut' screenshot-windows.jpeg
- run: |
cmd /r dir /s /b
- run: npx tsx script/e2e.mts 'dist\win-unpacked\LosslessCut.exe' desktop screenshot-windows.jpeg
if: startsWith(matrix.os, 'windows')

- run: |
export DISPLAY=:0
sudo Xvfb -ac :0 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sleep 1
ls -R dist/linux-x64
# chmod +x dist/linux-x64/LosslessCut
# npx tsx script/e2e.mts 'dist/linux-x64/LosslessCut' screenshot-linux.jpeg
sleep 5
ls -R dist
chmod +x dist/linux-x64/linux-unpacked/LosslessCut
npx tsx script/e2e.mts 'dist/linux-x64/linux-unpacked/LosslessCut' ':0.0+0,0' screenshot-linux.jpeg
if: startsWith(matrix.os, 'ubuntu')
- name: (MacOS) Upload to Mac App Store
Expand Down
19 changes: 15 additions & 4 deletions script/e2e.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import timers from 'node:timers/promises';

const losslessCutExePath = process.argv[2];
assert(losslessCutExePath);
const screenshotOutPath = process.argv[3];
const screenshotDevice = process.argv[3];
const screenshotOutPath = process.argv[4];
assert(screenshotOutPath);


Expand All @@ -26,10 +27,20 @@ const client = got.extend({ prefixUrl: `http://127.0.0.1:${port}`, timeout: { re
async function captureScreenshot(outPath: string) {
// https://trac.ffmpeg.org/wiki/Capture/Desktop#Windows

const platform = os.platform();

if (platform === 'darwin') {
const { stderr } = await execa('ffmpeg', ['-f', 'avfoundation', '-list_devices', 'true', '-i', '', '-hide_banner'], { reject: false });
console.log(stderr);
}

assert(screenshotDevice);

await execa('ffmpeg', [
...(os.platform() === 'darwin' ? ['-r', '30', '-pix_fmt', 'uyvy422', '-f', 'avfoundation', '-i', '1:none'] : []),
...(os.platform() === 'win32' ? ['-f', 'gdigrab', '-framerate', '30', '-i', 'desktop'] : []),
...(os.platform() === 'linux' ? ['-framerate', '25', '-f', 'x11grab', '-i', ':0.0+0,0'] : []),
...(platform === 'darwin' ? ['-r', '30', '-pix_fmt', 'uyvy422', '-f', 'avfoundation'] : []),
...(platform === 'win32' ? ['-f', 'gdigrab', '-framerate', '30'] : []),
...(platform === 'linux' ? ['-framerate', '25', '-f', 'x11grab'] : []),
'-i', screenshotDevice,
'-vframes', '1', outPath,
], { timeout: 30000 });
}
Expand Down

0 comments on commit 3461767

Please sign in to comment.