This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cd670a
commit 7cbbfbf
Showing
23 changed files
with
45 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import fs from 'fs/promises' | ||
import path from 'path' | ||
import { fetchFile } from '@ffmpeg/ffmpeg' | ||
import { PUBLIC_PATH } from './src/paths.js' | ||
import { ffmpeg } from './src/ffmpeg.js' | ||
|
||
const doneFiles = [] | ||
|
||
;(async () => { | ||
const dir = path.resolve(PUBLIC_PATH, './movies') | ||
|
||
console.log('Loading ffmpeg') | ||
await ffmpeg.load(); | ||
console.log('Loaded ffmpeg') | ||
|
||
const files = await fs.readdir(dir) | ||
console.log('Start convert files', files) | ||
for (const file of files) { | ||
if (path.extname(file) !== '.gif') continue | ||
const name = path.basename(file, '.gif') | ||
if (doneFiles.includes(name)) continue | ||
|
||
const newFile = `${name}.webm` | ||
|
||
const buf = await fetchFile(path.resolve(dir, file)) | ||
ffmpeg.FS('writeFile', 'file', buf) | ||
await ffmpeg.run('-i', 'file', '-movflags', 'faststart', '-pix_fmt', 'yuv420p', '-row-mt', '1', newFile) | ||
const exported = ffmpeg.FS('readFile', newFile) | ||
await fs.writeFile(path.resolve(dir, `./${newFile}`), exported, 'binary') | ||
console.log(`outputed: ${newFile}`) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters