mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Embed track number
This commit is contained in:
parent
a21b1f3b16
commit
4732ca8119
@ -138,7 +138,7 @@ class AudioMetadataMangaer {
|
||||
}
|
||||
}
|
||||
|
||||
const success = await ffmpegHelpers.addCoverAndMetadataToFile(af.path, task.data.coverPath, ffmetadataPath, task.data.mimeType)
|
||||
const success = await ffmpegHelpers.addCoverAndMetadataToFile(af.path, task.data.coverPath, ffmetadataPath, af.index, task.data.mimeType)
|
||||
if (success) {
|
||||
Logger.info(`[AudioMetadataManager] Successfully tagged audio file "${af.path}"`)
|
||||
}
|
||||
|
@ -225,9 +225,10 @@ module.exports.generateFFMetadata = generateFFMetadata
|
||||
* @param {string} audioFilePath - Path to the input audio file.
|
||||
* @param {string|null} coverFilePath - Path to the cover image file.
|
||||
* @param {string} metadataFilePath - Path to the ffmetadata file.
|
||||
* @param {number} track - The track number to embed in the audio file.
|
||||
* @param {string} mimeType - The MIME type of the audio file.
|
||||
*/
|
||||
async function addCoverAndMetadataToFile(audioFilePath, coverFilePath, metadataFilePath, mimeType) {
|
||||
async function addCoverAndMetadataToFile(audioFilePath, coverFilePath, metadataFilePath, track, mimeType) {
|
||||
const isMp4 = mimeType === 'audio/mp4'
|
||||
const isMp3 = mimeType === 'audio/mpeg'
|
||||
|
||||
@ -246,6 +247,10 @@ async function addCoverAndMetadataToFile(audioFilePath, coverFilePath, metadataF
|
||||
'-c copy' // copy streams
|
||||
])
|
||||
|
||||
if (track && !isNaN(track)) {
|
||||
ffmpeg.outputOptions(['-metadata track=' + track])
|
||||
}
|
||||
|
||||
if (isMp4) {
|
||||
ffmpeg.outputOptions([
|
||||
'-f mp4' // force output format to mp4
|
||||
|
Loading…
Reference in New Issue
Block a user