mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 08:17:35 +00:00
feat(metadata): add audio-related system metadata fields
This commit is contained in:
@@ -50,6 +50,10 @@ describe('Transcode Activities', () => {
|
||||
bitRate: 1000,
|
||||
frameRate: 30,
|
||||
hasAudio: true,
|
||||
audioCodec: 'aac',
|
||||
audioChannels: 2,
|
||||
audioSampleRate: 48000,
|
||||
audioBitDepth: 16,
|
||||
mimeType: 'video/mp4',
|
||||
})
|
||||
|
||||
@@ -62,6 +66,10 @@ describe('Transcode Activities', () => {
|
||||
expect(transcodeService.getVideoInfo).toHaveBeenCalledWith('/tmp/v.mp4')
|
||||
expect(result.duration).toBe(10)
|
||||
expect(result.metadata?.originalWidth).toBe(1920)
|
||||
expect(result.metadata?.audioCodec).toBe('aac')
|
||||
expect(result.metadata?.audioChannels).toBe(2)
|
||||
expect(result.metadata?.audioSampleRate).toBe(48000)
|
||||
expect(result.metadata?.audioBitDepth).toBe(16)
|
||||
})
|
||||
|
||||
it('should call getImageInfo for image assets', async () => {
|
||||
|
||||
@@ -49,15 +49,28 @@ export async function getMediaInfoActivity(params: {
|
||||
bitRate: info.bitRate,
|
||||
frameRate: info.frameRate,
|
||||
hasAudio: info.hasAudio,
|
||||
audioCodec: info.audioCodec,
|
||||
audioChannels: info.audioChannels,
|
||||
audioSampleRate: info.audioSampleRate,
|
||||
audioBitDepth: info.audioBitDepth,
|
||||
format: {},
|
||||
}
|
||||
await metadataService.updateAssetMetadata(params.assetId, [
|
||||
const metadataUpdates: { key: string; value: string | number }[] = [
|
||||
{ key: 'resolution_width', value: info.originalWidth },
|
||||
{ key: 'resolution_height', value: info.originalHeight },
|
||||
{ key: 'duration', value: info.duration },
|
||||
{ key: 'bitRate', value: info.bitRate / 1000 },
|
||||
{ key: 'frame_rate', value: info.frameRate },
|
||||
])
|
||||
]
|
||||
if (info.audioCodec) metadataUpdates.push({ key: 'audio_codec', value: info.audioCodec })
|
||||
if (info.audioChannels !== undefined)
|
||||
metadataUpdates.push({ key: 'audio_channels', value: info.audioChannels })
|
||||
if (info.audioSampleRate !== undefined)
|
||||
metadataUpdates.push({ key: 'audio_sample_rate', value: info.audioSampleRate })
|
||||
if (info.audioBitDepth !== undefined)
|
||||
metadataUpdates.push({ key: 'audio_bit_depth', value: info.audioBitDepth })
|
||||
|
||||
await metadataService.updateAssetMetadata(params.assetId, metadataUpdates)
|
||||
} else if (isImage) {
|
||||
const info = await transcodeService.getImageInfo(params.filePath)
|
||||
mediaInfo.metadata = {
|
||||
|
||||
Reference in New Issue
Block a user