mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Merge tracks with codec copy'
This commit is contained in:
parent
315de87bfc
commit
ddbf678a8b
@ -106,7 +106,9 @@ export default {
|
|||||||
|
|
||||||
var downloadPayload = {
|
var downloadPayload = {
|
||||||
audiobookId: this.audiobook.id,
|
audiobookId: this.audiobook.id,
|
||||||
type: 'singleAudio'
|
type: 'singleAudio',
|
||||||
|
includeMetadata: true,
|
||||||
|
includeCover: true
|
||||||
}
|
}
|
||||||
this.$root.socket.emit('download', downloadPayload)
|
this.$root.socket.emit('download', downloadPayload)
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "Audiobook manager and player",
|
"description": "Audiobook manager and player",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -65,10 +65,14 @@ class DownloadManager {
|
|||||||
var audiobookDirname = Path.basename(audiobook.path)
|
var audiobookDirname = Path.basename(audiobook.path)
|
||||||
|
|
||||||
if (downloadType === 'singleAudio') {
|
if (downloadType === 'singleAudio') {
|
||||||
var audioFileType = options.audioFileType || 'm4b'
|
var audioFileType = options.audioFileType || '.m4b'
|
||||||
delete options.audioFileType
|
delete options.audioFileType
|
||||||
filename = audiobookDirname + '.' + audioFileType
|
if (audioFileType === 'same') {
|
||||||
fileext = '.' + audioFileType
|
var firstTrack = audiobook.tracks[0]
|
||||||
|
audioFileType = firstTrack.ext
|
||||||
|
}
|
||||||
|
filename = audiobookDirname + audioFileType
|
||||||
|
fileext = audioFileType
|
||||||
filepath = Path.join(dlpath, filename)
|
filepath = Path.join(dlpath, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,33 +101,47 @@ class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async processSingleAudioDownload(audiobook, download) {
|
async processSingleAudioDownload(audiobook, download) {
|
||||||
|
|
||||||
|
// If changing audio file type then encoding is needed
|
||||||
|
var requiresEncode = audiobook.tracks[0].ext !== download.ext || download.includeCover || download.includeMetadata
|
||||||
|
|
||||||
var concatFilePath = Path.join(download.dirpath, 'files.txt')
|
var concatFilePath = Path.join(download.dirpath, 'files.txt')
|
||||||
await writeConcatFile(audiobook.tracks, concatFilePath)
|
await writeConcatFile(audiobook.tracks, concatFilePath)
|
||||||
|
|
||||||
var metadataFilePath = Path.join(download.dirpath, 'metadata.txt')
|
|
||||||
await writeMetadataFile(audiobook, metadataFilePath)
|
|
||||||
|
|
||||||
const ffmpegInputs = [
|
const ffmpegInputs = [
|
||||||
{
|
{
|
||||||
input: concatFilePath,
|
input: concatFilePath,
|
||||||
options: ['-safe 0', '-f concat']
|
options: ['-safe 0', '-f concat']
|
||||||
},
|
|
||||||
{
|
|
||||||
input: metadataFilePath
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const logLevel = process.env.NODE_ENV === 'production' ? 'error' : 'warning'
|
const logLevel = process.env.NODE_ENV === 'production' ? 'error' : 'warning'
|
||||||
const ffmpegOptions = [
|
var ffmpegOptions = [`-loglevel ${logLevel}`]
|
||||||
`-loglevel ${logLevel}`,
|
|
||||||
'-map 0:a',
|
|
||||||
'-map_metadata 1',
|
|
||||||
'-acodec aac',
|
|
||||||
'-ac 2',
|
|
||||||
'-b:a 64k',
|
|
||||||
'-id3v2_version 3']
|
|
||||||
|
|
||||||
if (audiobook.book.cover) {
|
if (requiresEncode) {
|
||||||
|
ffmpegOptions = ffmpegOptions.concat([
|
||||||
|
'-map 0:a',
|
||||||
|
'-acodec aac',
|
||||||
|
'-ac 2',
|
||||||
|
'-b:a 64k',
|
||||||
|
'-id3v2_version 3'
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
ffmpegOptions.push('-c copy')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (download.includeMetadata) {
|
||||||
|
var metadataFilePath = Path.join(download.dirpath, 'metadata.txt')
|
||||||
|
await writeMetadataFile(audiobook, metadataFilePath)
|
||||||
|
|
||||||
|
ffmpegInputs.push({
|
||||||
|
input: metadataFilePath
|
||||||
|
})
|
||||||
|
|
||||||
|
ffmpegOptions.push('-map_metadata 1')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (download.includeCover && audiobook.book.cover) {
|
||||||
ffmpegInputs.push({
|
ffmpegInputs.push({
|
||||||
input: audiobook.book.cover,
|
input: audiobook.book.cover,
|
||||||
options: ['-f image2pipe']
|
options: ['-f image2pipe']
|
||||||
|
@ -28,6 +28,14 @@ class Download {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get includeMetadata() {
|
||||||
|
return !!this.options.includeMetadata
|
||||||
|
}
|
||||||
|
|
||||||
|
get includeCover() {
|
||||||
|
return !!this.options.includeCover
|
||||||
|
}
|
||||||
|
|
||||||
get mimeType() {
|
get mimeType() {
|
||||||
if (this.ext === '.mp3' || this.ext === '.m4b' || this.ext === '.m4a') {
|
if (this.ext === '.mp3' || this.ext === '.m4b' || this.ext === '.m4a') {
|
||||||
return 'audio/mpeg'
|
return 'audio/mpeg'
|
||||||
|
Loading…
Reference in New Issue
Block a user