persist the advanced encoding options, show the encoding options used with in progress encodes

This commit is contained in:
Shaun 2024-07-31 16:44:24 +10:00
parent 787c4e45a8
commit 49054d5239
2 changed files with 29 additions and 6 deletions

View File

@ -78,7 +78,7 @@
<!-- m4b embed action buttons --> <!-- m4b embed action buttons -->
<div v-else class="w-full flex items-center mb-4"> <div v-else class="w-full flex items-center mb-4">
<button :disabled="processing" class="text-sm uppercase text-gray-200 flex items-center pt-px pl-1 pr-2 hover:bg-white/5 rounded-md" @click="showEncodeOptions = !showEncodeOptions"> <button :disabled="processing" class="text-sm uppercase text-gray-200 flex items-center pt-px pl-1 pr-2 hover:bg-white/5 rounded-md" @click="showEncodeOptions = !showEncodeOptions">
<span class="material-symbols text-xl">{{ showEncodeOptions ? 'check_box' : 'check_box_outline_blank' }}</span> <span class="pl-1">Use Advanced Options</span> <span class="material-symbols text-xl">{{ showEncodeOptions || usingCustomEncodeOptions ? 'check_box' : 'check_box_outline_blank' }}</span> <span class="pl-1">Use Advanced Options</span>
</button> </button>
<div class="flex-grow" /> <div class="flex-grow" />
@ -92,11 +92,11 @@
<!-- advanced encoding options --> <!-- advanced encoding options -->
<div v-if="isM4BTool" class="overflow-hidden"> <div v-if="isM4BTool" class="overflow-hidden">
<transition name="slide"> <transition name="slide">
<div v-if="showEncodeOptions" class="mb-4 pb-4 border-b border-white/10"> <div v-if="showEncodeOptions || usingCustomEncodeOptions" class="mb-4 pb-4 border-b border-white/10">
<div class="flex flex-wrap -mx-2"> <div class="flex flex-wrap -mx-2">
<ui-text-input-with-label ref="bitrateInput" v-model="encodingOptions.bitrate" :disabled="processing || isTaskFinished" :label="'Audio Bitrate (e.g. 128k)'" class="m-2 max-w-40" /> <ui-text-input-with-label ref="bitrateInput" v-model="encodingOptions.bitrate" :disabled="processing || isTaskFinished" :label="'Audio Bitrate (e.g. 128k)'" class="m-2 max-w-40" @input="bitrateChanged" />
<ui-text-input-with-label ref="channelsInput" v-model="encodingOptions.channels" :disabled="processing || isTaskFinished" :label="'Audio Channels (1 or 2)'" class="m-2 max-w-40" /> <ui-text-input-with-label ref="channelsInput" v-model="encodingOptions.channels" :disabled="processing || isTaskFinished" :label="'Audio Channels (1 or 2)'" class="m-2 max-w-40" @input="channelsChanged" />
<ui-text-input-with-label ref="codecInput" v-model="encodingOptions.codec" :disabled="processing || isTaskFinished" :label="'Audio Codec'" class="m-2 max-w-40" /> <ui-text-input-with-label ref="codecInput" v-model="encodingOptions.codec" :disabled="processing || isTaskFinished" :label="'Audio Codec'" class="m-2 max-w-40" @input="codecChanged" />
</div> </div>
<p class="text-sm text-warning">Warning: Do not update these settings unless you are familiar with ffmpeg encoding options.</p> <p class="text-sm text-warning">Warning: Do not update these settings unless you are familiar with ffmpeg encoding options.</p>
</div> </div>
@ -308,12 +308,24 @@ export default {
}, },
isMetadataEmbedQueued() { isMetadataEmbedQueued() {
return this.queuedEmbedLIds.some((lid) => lid === this.libraryItemId) return this.queuedEmbedLIds.some((lid) => lid === this.libraryItemId)
},
usingCustomEncodeOptions() {
return this.isM4BTool && this.encodeTask && this.encodeTask.data.encodeOptions && Object.keys(this.encodeTask.data.encodeOptions).length > 0
} }
}, },
methods: { methods: {
toggleBackupAudioFiles(val) { toggleBackupAudioFiles(val) {
localStorage.setItem('embedMetadataShouldBackup', val ? 1 : 0) localStorage.setItem('embedMetadataShouldBackup', val ? 1 : 0)
}, },
bitrateChanged(val) {
localStorage.setItem('embedMetadataBitrate', val)
},
channelsChanged(val) {
localStorage.setItem('embedMetadataChannels', val)
},
codecChanged(val) {
localStorage.setItem('embedMetadataCodec', val)
},
cancelEncodeClick() { cancelEncodeClick() {
this.isCancelingEncode = true this.isCancelingEncode = true
this.$axios this.$axios
@ -398,6 +410,16 @@ export default {
const shouldBackupAudioFiles = localStorage.getItem('embedMetadataShouldBackup') const shouldBackupAudioFiles = localStorage.getItem('embedMetadataShouldBackup')
this.shouldBackupAudioFiles = shouldBackupAudioFiles != 0 this.shouldBackupAudioFiles = shouldBackupAudioFiles != 0
if (this.usingCustomEncodeOptions) {
if (this.encodeTask.data.encodeOptions.bitrate) this.encodingOptions.bitrate = this.encodeTask.data.encodeOptions.bitrate
if (this.encodeTask.data.encodeOptions.channels) this.encodingOptions.channels = this.encodeTask.data.encodeOptions.channels
if (this.encodeTask.data.encodeOptions.codec) this.encodingOptions.codec = this.encodeTask.data.encodeOptions.codec
} else {
this.encodingOptions.bitrate = localStorage.getItem('embedMetadataBitrate') || '128k'
this.encodingOptions.channels = localStorage.getItem('embedMetadataChannels') || '2'
this.encodingOptions.codec = localStorage.getItem('embedMetadataCodec') || 'aac'
}
}, },
fetchMetadataEmbedObject() { fetchMetadataEmbedObject() {
this.$axios this.$axios

View File

@ -48,7 +48,8 @@ class AbMergeManager {
chapters: libraryItem.media.chapters?.map((c) => ({ ...c })), chapters: libraryItem.media.chapters?.map((c) => ({ ...c })),
coverPath: libraryItem.media.coverPath, coverPath: libraryItem.media.coverPath,
ffmetadataPath, ffmetadataPath,
duration: libraryItem.media.duration duration: libraryItem.media.duration,
encodeOptions: options
} }
const taskDescription = `Encoding audiobook "${libraryItem.media.metadata.title}" into a single m4b file.` const taskDescription = `Encoding audiobook "${libraryItem.media.metadata.title}" into a single m4b file.`
task.setData('encode-m4b', 'Encoding M4b', taskDescription, false, taskData) task.setData('encode-m4b', 'Encoding M4b', taskDescription, false, taskData)