Skip to content

Commit

Permalink
Merge pull request #3776 from mikiher/fix-ffmpeg-concat-file
Browse files Browse the repository at this point in the history
Fix ffmpeg concat file escaping
  • Loading branch information
advplyr authored Jan 4, 2025
2 parents f366dfa + fe2ba08 commit fdbca4f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/utils/ffmpegHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit fdbca4f

Please sign in to comment.