Skip to content

Commit

Permalink
clearDir
Browse files Browse the repository at this point in the history
  • Loading branch information
denisavitski committed Apr 25, 2024
1 parent 449e681 commit 0c9afec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
dist
lib
playground/source
package-lock.json
.DS_Store
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automizer",
"version": "0.1.1",
"version": "0.1.2",
"repository": {
"type": "git",
"url": "git+https://github.com/denisavitski/automizer.git"
Expand Down
29 changes: 13 additions & 16 deletions playground/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// import { ImageSequenceGenerator } from '../src'
// import { BackgroundRemoval } from '../src/generators/BackgroundRemoval'

// // console.log('A')

// await new ImageSequenceGenerator({
// srcFolder: 'playground/source/video/1.mp4',
// destFolder: 'playground/source/video/seq',
// }).generate()

// console.log('B')

// await new BackgroundRemoval({
// srcFolder: 'playground/source/video/seq',
// destFolder: 'playground/source/video/seq-wb',
// }).generate()
import { ImageSequenceGenerator } from '../src'
import { BackgroundRemoval } from '../src/generators/BackgroundRemoval'

await new ImageSequenceGenerator({
srcFolder: 'playground/source/video/1.mp4',
destFolder: 'playground/source/video/seq',
fps: 40,
}).generate()

await new BackgroundRemoval({
srcFolder: 'playground/source/video/seq',
destFolder: 'playground/source/video/seq-wb',
}).generate()
8 changes: 5 additions & 3 deletions src/generators/ImageSequenceGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import extractFrames from 'ffmpeg-extract-frames'
import { mkdirSync } from 'fs'

import { sep } from 'path'
import { clearDir } from '../utils/clearDir'

export interface ImageSequenceGeneratorParameters {
srcFolder: string
Expand All @@ -21,13 +22,14 @@ export class ImageSequenceGenerator {
constructor(parameters: ImageSequenceGeneratorParameters) {
this.#srcFolder = parameters.srcFolder
this.#destFolder = parameters.destFolder
this.#destPath = `${this.#destFolder}${sep}${parameters.name || 'frame'}-%d.${
parameters.extension || 'png'
}`
this.#destPath = `${this.#destFolder}${sep}${
parameters.name || 'frame'
}-%d.${parameters.extension || 'png'}`
this.#fps = parameters.fps || 60
}

public async generate() {
clearDir(this.#destFolder)
mkdirSync(this.#destFolder, { recursive: true })

return extractFrames({
Expand Down

0 comments on commit 0c9afec

Please sign in to comment.