Browse Source
- Install mediabunny@^1.28.0 for video processing - Add audioInput and videoStitch to NodeType union - Add AudioInputNodeData interface (audioFile, filename, duration, format) - Add VideoStitchClip interface for filmstrip items - Add VideoStitchNodeData interface (clips, clipOrder, outputVideo, progress, encoderSupported) - Update WorkflowNodeData union to include new node types - Extend HandleType to include audio and video handles - Create src/lib/video-encoding.ts with AVC encoding config helpershandoff-20260429-1057
4 changed files with 114 additions and 3 deletions
@ -0,0 +1,39 @@ |
|||||
|
import type { VideoEncodingConfig } from 'mediabunny'; |
||||
|
|
||||
|
// Inlined constants from easy-peasy-ease
|
||||
|
const DEFAULT_KEYFRAME_INTERVAL = 1.0; |
||||
|
const MAX_OUTPUT_FPS = 60; |
||||
|
|
||||
|
export const AVC_LEVEL_4_0 = 'avc1.420028'; |
||||
|
export const AVC_LEVEL_5_1 = 'avc1.640033'; |
||||
|
|
||||
|
export const createAvcEncodingConfig = ( |
||||
|
bitrate: number, |
||||
|
width?: number, |
||||
|
height?: number, |
||||
|
codecString: string = AVC_LEVEL_4_0, |
||||
|
framerate?: number, |
||||
|
useHardwareAcceleration: boolean = true |
||||
|
): VideoEncodingConfig => ({ |
||||
|
codec: 'avc', |
||||
|
bitrate, |
||||
|
keyFrameInterval: DEFAULT_KEYFRAME_INTERVAL, |
||||
|
bitrateMode: 'variable', |
||||
|
latencyMode: 'quality', |
||||
|
fullCodecString: codecString, |
||||
|
hardwareAcceleration: useHardwareAcceleration ? 'prefer-hardware' : 'prefer-software', |
||||
|
onEncoderConfig: (config) => { |
||||
|
config.avc = { ...(config.avc ?? {}), format: 'avc' }; |
||||
|
if (!config.latencyMode) { |
||||
|
config.latencyMode = 'quality'; |
||||
|
} |
||||
|
if (framerate && framerate > 0) { |
||||
|
config.framerate = framerate; |
||||
|
} else if (!config.framerate) { |
||||
|
config.framerate = MAX_OUTPUT_FPS; |
||||
|
} |
||||
|
config.bitrate = bitrate; |
||||
|
if (width) config.width = width; |
||||
|
if (height) config.height = height; |
||||
|
}, |
||||
|
}); |
||||
Loading…
Reference in new issue