Skip to content

Commit

Permalink
fix: windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Dec 6, 2023
1 parent 4174203 commit 27c1109
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/__tests__/ffmpeg.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const targetVersions = require('./ffmpegReleases.json')
const testMediaPath = path.join(__dirname, 'samples')

function runForFFmpegRelease(ffprobePath: string, ffmpegPath: string) {
console.log('ff', ffprobePath, ffmpegPath)
function createBareDoc(filename: string): PouchDBMediaDocument {
return {
_id: 'test',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ffmpegReleases.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/CasparCG/dependencies/releases/download/ffmpeg-binaries/ffmpeg-6.1-amd64-static.tar.xz"
}
],
"windows-x64": [
"win32-x64": [
{
"id": "4.1.4",
"url": "https://github.com/CasparCG/dependencies/releases/download/ffmpeg-binaries/ffmpeg-4.1.4-win64-static.zip"
Expand Down
8 changes: 6 additions & 2 deletions tools/fetch_ffmpeg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,22 @@ if (platformVersions) {
const versionPath = path.join(ffmpegRootDir, version.id)
const dirStat = await pathExists(versionPath)
if (!dirStat) {
console.log(`Fetching ${version.url}`)
// Download it

const response = await fetch(version.url)
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`)
await streamPipeline(response.body, createWriteStream(tmpPath))

// Extract it
await fs.mkdir(versionPath).catch(() => null)
if (versionPath.endsWith('.tar.xz')) {
await fs.mkdir(versionPath).catch(() => null)
cp.execSync(`tar -xJf ${toPosix(tmpPath)} --strip-components=1 -C ${toPosix(versionPath)}`)
} else if (version.url.endsWith('.zip')) {
cp.execSync(`unzip ${toPosix(tmpPath)} -d ${toPosix(versionPath)}`)
cp.execSync(`unzip ${toPosix(tmpPath)} -d ${toPosix(ffmpegRootDir)}`)

const dirname = path.parse(version.url).name
await fs.rename(path.join(ffmpegRootDir, dirname), versionPath)
} else {
throw new Error(`Unhandled file extension: ${version.url}`)
}
Expand Down

0 comments on commit 27c1109

Please sign in to comment.