From 65bb8ecd2bafa8a7a13997b83868717a38bed728 Mon Sep 17 00:00:00 2001 From: Jonas Kamsker <11245306+JKamsker@users.noreply.github.com> Date: Tue, 4 Jan 2022 16:05:40 +0100 Subject: [PATCH] Added string escape for DemuxConcatArgument Fixes issue when source files have a ``'`` in their path Former-commit-id: 21d1df824f54d311d2ce9e3b9e60d208687f370b --- FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs index c672c74..47564f9 100644 --- a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs @@ -16,8 +16,17 @@ public class DemuxConcatArgument : IInputArgument public readonly IEnumerable Values; public DemuxConcatArgument(IEnumerable values) { - Values = values.Select(value => $"file '{value}'"); + Values = values.Select(value => $"file '{Escape(value)}'"); } + + /// + /// Thanks slhck + /// https://superuser.com/a/787651/1089628 + /// + /// + /// + private string Escape(string value) => value.Replace("'", @"'\''"); + private readonly string _tempFileName = Path.Combine(GlobalFFOptions.Current.TemporaryFilesFolder, $"concat_{Guid.NewGuid()}.txt"); public void Pre() => File.WriteAllLines(_tempFileName, Values);