Skip to content

Commit

Permalink
Skip audio metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
starkdmi committed Apr 7, 2024
1 parent 3a1f5e8 commit 60b143c
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions Sources/Audio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,33 +150,38 @@ public struct AudioTool {

// MARK: Metadata

// Load file metadata
var metadata = await asset.getMetadata()
// Convert ID3 and other tags to common key space when possible
if !metadata.isEmpty {
var commonMetadata: [AVMetadataItem] = []

for item in metadata {
guard let key = item.commonKey else { continue }

let metadataItem = AVMutableMetadataItem()
metadataItem.key = key as NSString
metadataItem.keySpace = AVMetadataKeySpace.common
metadataItem.value = item.value
metadataItem.dataType = item.dataType
var metadata: [AVMetadataItem] = []
if !skipSourceMetadata {
// Load file metadata
metadata = await asset.getMetadata()
// Convert ID3 and other tags to common key space when possible
if !metadata.isEmpty {
var commonMetadata: [AVMetadataItem] = []

for item in metadata {
guard let key = item.commonKey else { continue }

let metadataItem = AVMutableMetadataItem()
metadataItem.key = key as NSString
metadataItem.keySpace = AVMetadataKeySpace.common
metadataItem.value = item.value
metadataItem.dataType = item.dataType

commonMetadata.append(metadataItem)
}

commonMetadata.append(metadataItem)
// Append converted tags without removing original items
metadata.append(contentsOf: commonMetadata)
}

// Append converted tags without removing original items
metadata.append(contentsOf: commonMetadata)
}

// Append custom metadata
metadata.append(contentsOf: customMetadata)

// Insert source file and custom metadata
writer.metadata = metadata
if !metadata.isEmpty {
writer.metadata = metadata
}

// MARK: Compression

Expand Down

0 comments on commit 60b143c

Please sign in to comment.