Skip to content

Commit

Permalink
Merge pull request #3111 from mikiher/tone-replacement
Browse files Browse the repository at this point in the history
Replace tone with ffmpeg for metadata and cover embedding
  • Loading branch information
advplyr authored Jul 6, 2024
2 parents 1e5787c + e6b1acf commit 9a4c5a1
Show file tree
Hide file tree
Showing 18 changed files with 542 additions and 448 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
curl tzdata ffmpeg && \
rm -rf /var/lib/apt/lists/*

# Move tone executable to appropriate directory
COPY --from=sandreas/tone:v0.1.5 /usr/local/bin/tone /usr/local/bin/
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN npm ci && npm cache clean --force
RUN npm run generate

### STAGE 1: Build server ###
FROM sandreas/tone:v0.1.5 AS tone
FROM node:20-alpine

ENV NODE_ENV=production
Expand All @@ -21,7 +20,6 @@ RUN apk update && \
g++ \
tini

COPY --from=tone /usr/local/bin/tone /usr/local/bin/
COPY --from=build /client/dist /client/dist
COPY index.js package* /
COPY server server
Expand Down
16 changes: 1 addition & 15 deletions build/debian/DEBIAN/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ install_ffmpeg() {
echo "Starting FFMPEG Install"

WGET="wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz --output-document=ffmpeg-git-amd64-static.tar.xz"
WGET_TONE="wget https://github.com/sandreas/tone/releases/download/v0.1.5/tone-0.1.5-linux-x64.tar.gz --output-document=tone-0.1.5-linux-x64.tar.gz"

if ! cd "$FFMPEG_INSTALL_DIR"; then
echo "Creating ffmpeg install dir at $FFMPEG_INSTALL_DIR"
Expand All @@ -63,26 +62,14 @@ install_ffmpeg() {
tar xvf ffmpeg-git-amd64-static.tar.xz --strip-components=1 --no-same-owner
rm ffmpeg-git-amd64-static.tar.xz

# Temp downloading tone library to the ffmpeg dir
echo "Getting tone.."
$WGET_TONE
tar xvf tone-0.1.5-linux-x64.tar.gz --strip-components=1 --no-same-owner
rm tone-0.1.5-linux-x64.tar.gz

echo "Good to go on Ffmpeg (& tone)... hopefully"
echo "Good to go on Ffmpeg... hopefully"
}

setup_config() {
if [ -f "$CONFIG_PATH" ]; then
echo "Existing config found."
cat $CONFIG_PATH

# TONE_PATH variable added in 2.1.6, if it doesnt exist then add it
if ! grep -q "TONE_PATH" "$CONFIG_PATH"; then
echo "Adding TONE_PATH to existing config"
echo "TONE_PATH=$FFMPEG_INSTALL_DIR/tone" >> "$CONFIG_PATH"
fi

else

if [ ! -d "$DEFAULT_DATA_DIR" ]; then
Expand All @@ -98,7 +85,6 @@ setup_config() {
CONFIG_PATH=$DEFAULT_DATA_DIR/config
FFMPEG_PATH=$FFMPEG_INSTALL_DIR/ffmpeg
FFPROBE_PATH=$FFMPEG_INSTALL_DIR/ffprobe
TONE_PATH=$FFMPEG_INSTALL_DIR/tone
PORT=$DEFAULT_PORT
HOST=$DEFAULT_HOST"

Expand Down
15 changes: 3 additions & 12 deletions client/components/modals/item/tabs/Tools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
<div class="w-full h-full overflow-hidden overflow-y-auto px-4 py-6">
<p class="text-xl font-semibold mb-2">{{ $strings.HeaderAudiobookTools }}</p>

<!-- alert for windows install -->
<widgets-alert v-if="isWindowsInstall" type="warning" class="my-8 text-base">Not supported for the Windows install yet</widgets-alert>

<!-- Merge to m4b -->
<div v-if="showM4bDownload && !isWindowsInstall" class="w-full border border-black-200 p-4 my-8">
<div v-if="showM4bDownload" class="w-full border border-black-200 p-4 my-8">
<div class="flex flex-wrap items-center">
<div>
<p class="text-lg">{{ $strings.LabelToolsMakeM4b }}</p>
Expand All @@ -23,7 +20,7 @@
</div>

<!-- Embed Metadata -->
<div v-if="mediaTracks.length && !isWindowsInstall" class="w-full border border-black-200 p-4 my-8">
<div v-if="mediaTracks.length" class="w-full border border-black-200 p-4 my-8">
<div class="flex items-center">
<div>
<p class="text-lg">{{ $strings.LabelToolsEmbedMetadata }}</p>
Expand Down Expand Up @@ -111,12 +108,6 @@ export default {
},
isEncodeTaskRunning() {
return this.encodeTask && !this.encodeTask?.isFinished
},
isWindowsInstall() {
return this.Source == 'windows'
},
Source() {
return this.$store.state.Source
}
},
methods: {
Expand All @@ -141,4 +132,4 @@ export default {
}
}
}
</script>
</script>
24 changes: 11 additions & 13 deletions client/pages/audiobook/_id/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
</div>
</div>

<div class="flex justify-center">
<div class="flex justify-center mb-2">
<div class="w-full max-w-2xl">
<p class="text-xl mb-1">{{ $strings.HeaderMetadataToEmbed }}</p>
<p class="mb-2 text-base text-gray-300">audiobookshelf uses <a href="https://github.com/sandreas/tone" target="_blank" class="hover:underline text-blue-400 hover:text-blue-300">tone</a> to write metadata.</p>
<p class="text-xl">{{ $strings.HeaderMetadataToEmbed }}</p>
</div>
<div class="w-full max-w-2xl"></div>
</div>
Expand All @@ -26,7 +25,7 @@
<div class="w-2/3 text-xs font-semibold uppercase text-gray-200">{{ $strings.LabelValue }}</div>
</div>
<div class="w-full max-h-72 overflow-auto">
<template v-for="(value, key, index) in toneObject">
<template v-for="(value, key, index) in metadataObject">
<div :key="key" class="flex py-1 px-4 text-sm" :class="index % 2 === 0 ? 'bg-primary bg-opacity-25' : ''">
<div class="w-1/3 font-semibold">{{ key }}</div>
<div class="w-2/3">
Expand Down Expand Up @@ -208,7 +207,7 @@ export default {
processing: false,
audiofilesEncoding: {},
audiofilesFinished: {},
toneObject: null,
metadataObject: null,
selectedTool: 'embed',
isCancelingEncode: false,
showEncodeOptions: false,
Expand Down Expand Up @@ -387,7 +386,7 @@ export default {
window.history.replaceState({ path: newurl }, '', newurl)
},
init() {
this.fetchToneObject()
this.fetchMetadataEmbedObject()
if (this.$route.query.tool === 'm4b') {
if (this.availableTools.some((t) => t.value === 'm4b')) {
this.selectedTool = 'm4b'
Expand All @@ -401,15 +400,14 @@ export default {
const shouldBackupAudioFiles = localStorage.getItem('embedMetadataShouldBackup')
this.shouldBackupAudioFiles = shouldBackupAudioFiles != 0
},
fetchToneObject() {
fetchMetadataEmbedObject() {
this.$axios
.$get(`/api/items/${this.libraryItemId}/tone-object`)
.then((toneObject) => {
delete toneObject.CoverFile
this.toneObject = toneObject
.$get(`/api/items/${this.libraryItemId}/metadata-object`)
.then((metadataObject) => {
this.metadataObject = metadataObject
})
.catch((error) => {
console.error('Failed to fetch tone object', error)
console.error('Failed to fetch metadata object', error)
})
},
taskUpdated(task) {
Expand All @@ -426,4 +424,4 @@ export default {
this.$root.socket.off('audiofile_metadata_finished', this.audiofileMetadataFinished)
}
}
</script>
</script>
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"graceful-fs": "^4.2.10",
"htmlparser2": "^8.0.1",
"lru-cache": "^10.0.3",
"node-tone": "^1.0.1",
"nodemailer": "^6.9.13",
"openid-client": "^5.6.1",
"p-throttle": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Audiobookshelf is a self-hosted audiobook and podcast server.
- Fetch metadata and cover art from several sources
- Chapter editor and chapter lookup (using [Audnexus API](https://audnex.us/))
- Merge your audio files into a single m4b
- Embed metadata and cover image into your audio files (using [Tone](https://github.com/sandreas/tone))
- Embed metadata and cover image into your audio files
- Basic ebook support and ereader
- Epub, pdf, cbr, cbz
- Send ebook to device (i.e. Kindle)
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/LibraryItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ class LibraryItemController {
})
}

getToneMetadataObject(req, res) {
getMetadataObject(req, res) {
if (!req.user.isAdminOrUp) {
Logger.error(`[LibraryItemController] Non-admin user attempted to get tone metadata object`, req.user)
Logger.error(`[LibraryItemController] Non-admin user attempted to get metadata object`, req.user)
return res.sendStatus(403)
}

Expand All @@ -570,7 +570,7 @@ class LibraryItemController {
return res.sendStatus(500)
}

res.json(this.audioMetadataManager.getToneMetadataObjectForApi(req.libraryItem))
res.json(this.audioMetadataManager.getMetadataObjectForApi(req.libraryItem))
}

// POST: api/items/:id/chapters
Expand Down
Loading

0 comments on commit 9a4c5a1

Please sign in to comment.