From d6c02ebb2c527871ff7e22efb2fcac29ddd6b0f9 Mon Sep 17 00:00:00 2001 From: jmt-gh Date: Sat, 4 Jun 2022 18:56:55 -0700 Subject: [PATCH] Support embedding cover art metadata Added support for chapter metadata in #678, but completely missed that coverart wasn't getting embedded in the embed metadata tool. This commit adds that in --- server/managers/AudioMetadataManager.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/managers/AudioMetadataManager.js b/server/managers/AudioMetadataManager.js index 255b90d8..34deaf8a 100644 --- a/server/managers/AudioMetadataManager.js +++ b/server/managers/AudioMetadataManager.js @@ -32,9 +32,11 @@ class AudioMetadataMangaer { var metadataFilePath = Path.join(outputDir, 'metadata.txt') await writeMetadataFile(libraryItem, metadataFilePath) + var coverPath = libraryItem.media.coverPath.replace(/\\/g, '/') + // TODO: Split into batches const proms = audioFiles.map(af => { - return this.updateAudioFileMetadata(libraryItem.id, af, outputDir, metadataFilePath) + return this.updateAudioFileMetadata(libraryItem.id, af, outputDir, metadataFilePath, coverPath) }) const results = await Promise.all(proms) @@ -51,7 +53,7 @@ class AudioMetadataMangaer { this.emitter('audio_metadata_finished', itemAudioMetadataPayload) } - updateAudioFileMetadata(libraryItemId, audioFile, outputDir, metadataFilePath) { + updateAudioFileMetadata(libraryItemId, audioFile, outputDir, metadataFilePath, coverPath) { return new Promise((resolve) => { const resultPayload = { libraryItemId, @@ -73,6 +75,10 @@ class AudioMetadataMangaer { }, { input: metadataFilePath + }, + { + input: coverPath, + options: ['-f image2pipe'] } ] @@ -84,7 +90,7 @@ class AudioMetadataMangaer { Ffmpeg premapped id3 tags: https://wiki.multimedia.cx/index.php/FFmpeg_Metadata */ - const ffmpegOptions = ['-c copy', '-map_chapters 1', '-map_metadata 1', `-metadata track=${audioFile.index}`, '-write_id3v2 1', '-movflags use_metadata_tags'] + const ffmpegOptions = ['-c copy', '-map_chapters 1', '-map_metadata 1', `-metadata track=${audioFile.index}`, '-write_id3v2 1', '-movflags use_metadata_tags', '-c:v copy', '-map 2:v', '-map 0:a'] var workerData = { inputs: ffmpegInputs, options: ffmpegOptions,