mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Add sampleRate and profile extraction for audio files
- Extract sampleRate and profile from audio streams in ffprobe output - Store sampleRate and profile in AudioFile objects - Expose sampleRate and profile through API endpoints - Add JSDoc documentation for new fields
This commit is contained in:
parent
122fc34a75
commit
fadd14484e
4 changed files with 18 additions and 5 deletions
|
|
@ -61,6 +61,8 @@ const libraryItemsBookFilters = require('../utils/queries/libraryItemsBookFilter
|
|||
* @property {string} timeBase
|
||||
* @property {number} channels
|
||||
* @property {string} channelLayout
|
||||
* @property {number} sampleRate
|
||||
* @property {string} profile
|
||||
* @property {ChapterObject[]} chapters
|
||||
* @property {Object} metaTags
|
||||
* @property {string} mimeType
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class AudioFile {
|
|||
this.timeBase = null
|
||||
this.channels = null
|
||||
this.channelLayout = null
|
||||
this.sampleRate = null
|
||||
this.profile = null
|
||||
this.chapters = []
|
||||
this.embeddedCoverArt = null
|
||||
|
||||
|
|
@ -62,6 +64,8 @@ class AudioFile {
|
|||
timeBase: this.timeBase,
|
||||
channels: this.channels,
|
||||
channelLayout: this.channelLayout,
|
||||
sampleRate: this.sampleRate,
|
||||
profile: this.profile,
|
||||
chapters: this.chapters,
|
||||
embeddedCoverArt: this.embeddedCoverArt,
|
||||
metaTags: this.metaTags?.toJSON() || {},
|
||||
|
|
@ -94,6 +98,8 @@ class AudioFile {
|
|||
this.timeBase = data.timeBase
|
||||
this.channels = data.channels
|
||||
this.channelLayout = data.channelLayout
|
||||
this.sampleRate = data.sampleRate
|
||||
this.profile = data.profile
|
||||
this.chapters = data.chapters
|
||||
this.embeddedCoverArt = data.embeddedCoverArt || null
|
||||
|
||||
|
|
@ -130,6 +136,8 @@ class AudioFile {
|
|||
this.timeBase = probeData.timeBase
|
||||
this.channels = probeData.channels
|
||||
this.channelLayout = probeData.channelLayout
|
||||
this.sampleRate = probeData.sampleRate
|
||||
this.profile = probeData.profile
|
||||
this.chapters = probeData.chapters || []
|
||||
this.metaTags = probeData.audioMetaTags
|
||||
this.embeddedCoverArt = probeData.embeddedCoverArt
|
||||
|
|
@ -137,7 +145,7 @@ class AudioFile {
|
|||
|
||||
syncChapters(updatedChapters) {
|
||||
if (this.chapters.length !== updatedChapters.length) {
|
||||
this.chapters = updatedChapters.map(ch => ({ ...ch }))
|
||||
this.chapters = updatedChapters.map((ch) => ({ ...ch }))
|
||||
return true
|
||||
} else if (updatedChapters.length === 0) {
|
||||
if (this.chapters.length > 0) {
|
||||
|
|
@ -154,7 +162,7 @@ class AudioFile {
|
|||
}
|
||||
}
|
||||
if (hasUpdates) {
|
||||
this.chapters = updatedChapters.map(ch => ({ ...ch }))
|
||||
this.chapters = updatedChapters.map((ch) => ({ ...ch }))
|
||||
}
|
||||
return hasUpdates
|
||||
}
|
||||
|
|
@ -164,8 +172,8 @@ class AudioFile {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {AudioFile} scannedAudioFile
|
||||
*
|
||||
* @param {AudioFile} scannedAudioFile
|
||||
* @returns {boolean} true if updates were made
|
||||
*/
|
||||
updateFromScan(scannedAudioFile) {
|
||||
|
|
@ -196,4 +204,4 @@ class AudioFile {
|
|||
return hasUpdated
|
||||
}
|
||||
}
|
||||
module.exports = AudioFile
|
||||
module.exports = AudioFile
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class MediaProbeData {
|
|||
this.channelLayout = null
|
||||
this.channels = null
|
||||
this.sampleRate = null
|
||||
this.profile = null
|
||||
this.chapters = []
|
||||
|
||||
this.audioMetaTags = null
|
||||
|
|
@ -58,6 +59,7 @@ class MediaProbeData {
|
|||
this.channelLayout = this.audioStream.channel_layout
|
||||
this.channels = this.audioStream.channels
|
||||
this.sampleRate = this.audioStream.sample_rate
|
||||
this.profile = this.audioStream.profile
|
||||
this.chapters = data.chapters || []
|
||||
|
||||
this.audioMetaTags = new AudioMetaTags()
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ function parseMediaStreamInfo(stream, all_streams, total_bit_rate) {
|
|||
info.channels = stream.channels || null
|
||||
info.sample_rate = tryGrabSampleRate(stream)
|
||||
info.channel_layout = tryGrabChannelLayout(stream)
|
||||
info.profile = stream.profile || null
|
||||
}
|
||||
|
||||
return info
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue