MCPcopy Index your code
hub / github.com/simstudioai/sim / getAudioMetadata

Function getAudioMetadata

apps/sim/lib/audio/extractor.ts:187–207  ·  view source on GitHub ↗
(buffer: Buffer, mimeType: string)

Source from the content-addressed store, hash-verified

185 * Get audio metadata using ffprobe
186 */
187export async function getAudioMetadata(buffer: Buffer, mimeType: string): Promise<AudioMetadata> {
188 ensureFfmpeg() // Initialize FFmpeg/ffprobe
189 const tempDir = os.tmpdir()
190 const inputExt = getExtensionFromMimeType(mimeType)
191 const inputFile = path.join(tempDir, `ffprobe-input-${Date.now()}.${inputExt}`)
192
193 try {
194 // Write buffer to temporary file
195 await fs.writeFile(inputFile, buffer)
196
197 // Get metadata using ffprobe
198 return await getAudioMetadataFromFile(inputFile)
199 } finally {
200 // Clean up temporary file
201 try {
202 await fs.unlink(inputFile).catch(() => {})
203 } catch (error) {
204 // Ignore cleanup errors
205 }
206 }
207}
208
209/**
210 * Get audio metadata from a file path using ffprobe

Callers 1

extractAudioFromVideoFunction · 0.85

Calls 5

getAudioMetadataFromFileFunction · 0.85
joinMethod · 0.80
ensureFfmpegFunction · 0.70
getExtensionFromMimeTypeFunction · 0.70
writeFileMethod · 0.65

Tested by

no test coverage detected