Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 6, 2024
1 parent f909ed9 commit 26df795
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion scripts/fetch-ffmpeg.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* This is a small helper to download and extract a set of ffmpeg binaries.
* It reads the file `./tests/ffmpegReleases.json` to see what versions should be downloaded,
* and puts them into `.ffmpeg/` at the root of the repository.
*/

import fs from 'fs/promises'
import { pipeline } from 'node:stream'
import { promisify } from 'node:util'
Expand Down Expand Up @@ -73,5 +79,5 @@ if (platformVersions) {
}
}
} else {
throw new Error(`FFmpeg downloading for "${platformInfo}" not supported yet`)
throw new Error(`No FFMpeg binaries have been defined for "${platformInfo}" yet`)
}
13 changes: 7 additions & 6 deletions shared/packages/worker/src/__tests__/ffmpegHelper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import path from 'path'
import { LocalFolderAccessorHandle } from '../worker/accessorHandlers/localFolder'
import { setFFMpegExecutables, spawnFFMpeg } from '../worker/workers/windowsWorker/expectationHandlers/lib/ffmpeg'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const targetVersions = require('../../../../../tests/ffmpegReleases.json')
import { overrideFFMpegExecutables, spawnFFMpeg } from '../worker/workers/windowsWorker/expectationHandlers/lib/ffmpeg'

export const SamplesDir = path.join(__dirname, '../../../../../tests/samples')

Expand Down Expand Up @@ -32,16 +29,20 @@ export function runForEachFFMpegRelease(runForFFmpegRelease: () => void) {
const ffmpegFilename = process.platform === 'win32' ? 'bin/ffmpeg.exe' : 'ffmpeg'

const ffmpegRootPath = path.join(__dirname, '../../../../../.ffmpeg')

// eslint-disable-next-line @typescript-eslint/no-var-requires
const targetVersions = require('../../../../../tests/ffmpegReleases.json')

for (const version of targetVersions[`${process.platform}-${process.arch}`]) {
describe(`FFmpeg ${version.id}`, () => {
beforeEach(() => {
setFFMpegExecutables({
overrideFFMpegExecutables({
ffmpeg: path.join(ffmpegRootPath, version.id, ffmpegFilename),
ffprobe: path.join(ffmpegRootPath, version.id, ffprobeFilename),
})
})
afterAll(() => {
setFFMpegExecutables(null)
overrideFFMpegExecutables(null)
})

runForFFmpegRelease()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export interface OverriddenFFMpegExecutables {
}

let overriddenFFMpegPaths: OverriddenFFMpegExecutables | null = null
export function setFFMpegExecutables(paths: OverriddenFFMpegExecutables | null): void {
/**
* Override the paths of the ffmpeg executables, intended for unit testing purposes
* @param paths Paths to executables
*/
export function overrideFFMpegExecutables(paths: OverriddenFFMpegExecutables | null): void {
overriddenFFMpegPaths = paths
}

Expand Down

0 comments on commit 26df795

Please sign in to comment.