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

Function getAudioMetadataFromFile

apps/sim/lib/audio/extractor.ts:212–234  ·  view source on GitHub ↗

* Get audio metadata from a file path using ffprobe

(filePath: string)

Source from the content-addressed store, hash-verified

210 * Get audio metadata from a file path using ffprobe
211 */
212async function getAudioMetadataFromFile(filePath: string): Promise<AudioMetadata> {
213 ensureFfmpeg() // Initialize FFmpeg/ffprobe
214 return new Promise((resolve, reject) => {
215 ffmpeg.ffprobe(filePath, (err, metadata) => {
216 if (err) {
217 reject(new Error(`FFprobe error: ${err.message}`))
218 return
219 }
220
221 const audioStream = metadata.streams.find((s) => s.codec_type === 'audio')
222 const format = metadata.format
223
224 resolve({
225 duration: format.duration || 0,
226 format: format.format_name || 'unknown',
227 codec: audioStream?.codec_name,
228 sampleRate: audioStream?.sample_rate,
229 channels: audioStream?.channels,
230 bitrate: format.bit_rate ? Number(format.bit_rate) : undefined,
231 })
232 })
233 })
234}
235
236/**
237 * Get file extension from MIME type

Callers 2

convertAudioWithFFmpegFunction · 0.85
getAudioMetadataFunction · 0.85

Calls 2

ensureFfmpegFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected