From fe2ba083be74de090f359c544f8e03bfe542dd34 Mon Sep 17 00:00:00 2001 From: mikiher Date: Thu, 2 Jan 2025 13:34:25 +0200 Subject: [PATCH] Fix ffmpeg concat file escaping --- server/utils/ffmpegHelpers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/utils/ffmpegHelpers.js b/server/utils/ffmpegHelpers.js index c7024225..db0f23a0 100644 --- a/server/utils/ffmpegHelpers.js +++ b/server/utils/ffmpegHelpers.js @@ -8,8 +8,8 @@ const { filePathToPOSIX, copyToExisting } = require('./fileUtils') const LibraryItem = require('../objects/LibraryItem') function escapeSingleQuotes(path) { - // return path.replace(/'/g, '\'\\\'\'') - return filePathToPOSIX(path).replace(/ /g, '\\ ').replace(/'/g, "\\'") + // A ' within a quoted string is escaped with '\'' in ffmpeg (see https://www.ffmpeg.org/ffmpeg-utils.html#Quoting-and-escaping) + return filePathToPOSIX(path).replace(/'/g, "'\\''") } // Returns first track start time @@ -33,7 +33,7 @@ async function writeConcatFile(tracks, outputPath, startTime = 0) { var tracksToInclude = tracks.filter((t) => t.index >= trackToStartWithIndex) var trackPaths = tracksToInclude.map((t) => { - var line = 'file ' + escapeSingleQuotes(t.metadata.path) + '\n' + `duration ${t.duration}` + var line = "file '" + escapeSingleQuotes(t.metadata.path) + "'\n" + `duration ${t.duration}` return line }) var inputstr = trackPaths.join('\n\n')