-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
12 changed files
with
240 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import { resolve } from 'node:path' | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' | ||
import react from '@vitejs/plugin-react' | ||
import { resolve } from 'node:path'; | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; | ||
import react from '@vitejs/plugin-react'; | ||
import { viteStaticCopy } from 'vite-plugin-static-copy'; | ||
import svgr from 'vite-plugin-svgr'; | ||
import { normalizePath } from 'vite' | ||
import { normalizePath } from 'vite'; | ||
|
||
export default defineConfig({ | ||
main: { | ||
build: { | ||
rollupOptions: { | ||
external: ['@brick-a-brack/napi-canon-cameras'] | ||
} | ||
external: ['@brick-a-brack/napi-canon-cameras'], | ||
}, | ||
}, | ||
plugins: [externalizeDepsPlugin()] | ||
plugins: [externalizeDepsPlugin()], | ||
}, | ||
preload: { | ||
plugins: [externalizeDepsPlugin()] | ||
plugins: [externalizeDepsPlugin()], | ||
}, | ||
renderer: { | ||
resolve: { | ||
alias: { | ||
'~': resolve(__dirname) | ||
} | ||
'~': resolve(__dirname), | ||
}, | ||
}, | ||
plugins: [ | ||
react(), | ||
svgr({ | ||
include: '**/*.svg?jsx', | ||
svgrOptions: { | ||
// svgr options | ||
} | ||
}, | ||
}), | ||
viteStaticCopy({ | ||
targets: [ | ||
{ | ||
src: normalizePath(resolve(__dirname, './resources/*')), | ||
dest: '.' | ||
} | ||
] | ||
}) | ||
targets: [ | ||
{ | ||
src: normalizePath(resolve(__dirname, './resources/*')), | ||
dest: '.', | ||
}, | ||
], | ||
}), | ||
], | ||
} | ||
}) | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
const profiles = { | ||
h264: { | ||
codec: 'libx264', | ||
extension: 'mp4', | ||
pix_fmt: 'yuv420p', | ||
preset: 'faster', | ||
}, | ||
hevc: { | ||
codec: 'libx265', | ||
extension: 'mp4', | ||
pix_fmt: 'yuv420p', | ||
preset: 'faster', | ||
}, | ||
prores: { | ||
codec: 'prores_ks', | ||
extension: 'mov', | ||
pix_fmt: 'yuva444p10le', | ||
}, | ||
vp8: { | ||
codec: 'libvpx', | ||
extension: 'webm', | ||
pix_fmt: 'yuv420p', | ||
}, | ||
vp9: { | ||
codec: 'libvpx-vp9', | ||
extension: 'webm', | ||
pix_fmt: 'yuv420p', | ||
}, | ||
}; | ||
|
||
export const getEncodingProfile = (format) => { | ||
return profiles[format] || null; | ||
}; | ||
|
||
export const getFFmpegArgs = (width = 1920, height = 1080, encodingProfile = false, outputFile = false, fps = 24, opts = {}) => { | ||
if (typeof profiles[encodingProfile] === 'undefined') { | ||
throw new Error('UNKNOWN_PROFILE'); | ||
} | ||
|
||
// Get profile | ||
const profile = profiles[encodingProfile]; | ||
|
||
// Invalid output file | ||
if (outputFile === false) { | ||
throw new Error('UNDEFINED_OUTPUT'); | ||
} | ||
|
||
// Default -y to overwite | ||
const args = ['-y']; | ||
|
||
// Input framerate | ||
args.push('-r', `${Number(fps) > 0 && Number(fps) <= 240 ? Number(fps) : 12}`); | ||
|
||
// Add all images in the path | ||
args.push('-i', 'frame-%06d.jpg'); | ||
|
||
// Output resolution | ||
const customHeight = opts.resolution && opts.resolution !== 'original' ? `,scale=w=-2:h=${opts.resolution}:force_original_aspect_ratio=1` : ''; | ||
|
||
// AutoScale input to ratio | ||
args.push('-vf', `scale=w=${width}:h=${height}:force_original_aspect_ratio=1,pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2${customHeight}`); | ||
|
||
// Codec | ||
args.push('-c:v', profile.codec); | ||
|
||
// Bitrate | ||
//args.push('-b:v', '128M'); | ||
|
||
// Preset | ||
if (profile.preset) { | ||
args.push('-preset', profile.preset); | ||
} | ||
|
||
// Fast start for streaming | ||
if (profile.extension === 'mp4') { | ||
args.push('-movflags', '+faststart'); | ||
} | ||
|
||
// Custom output framerate | ||
if (opts.customOutputFramerate && opts.customOutputFramerateNumber) { | ||
args.push('-r', `${Number(opts.customOutputFramerateNumber)}`); | ||
} | ||
|
||
// Pixel mode | ||
args.push('-pix_fmt', profile.pix_fmt); | ||
|
||
// Prores flags | ||
if (encodingProfile === 'prores') { | ||
args.push('-profile:v', '3', '-vendor', 'apl0', '-bits_per_mb', '4000', '-f', 'mov'); | ||
} | ||
|
||
// Output file | ||
args.push(`${outputFile}`); | ||
|
||
return args; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FFmpeg } from '@ffmpeg/ffmpeg'; | ||
import { toBlobURL } from '@ffmpeg/util'; | ||
|
||
export const getFFmpeg = async (callback = () => {}) => { | ||
const baseURL = '/'; | ||
const ffmpeg = new FFmpeg(); | ||
ffmpeg.on('log', callback); | ||
ffmpeg.on('error', callback); | ||
ffmpeg.on('progress', callback); | ||
await ffmpeg | ||
.load({ | ||
coreURL: await toBlobURL(`${baseURL}ffmpeg-core.js`, 'text/javascript'), | ||
wasmURL: await toBlobURL(`${baseURL}ffmpeg-core.wasm`, 'application/wasm'), | ||
}) | ||
.catch(console.error); | ||
return ffmpeg; | ||
}; |
Oops, something went wrong.