diff --git a/core/ffmpeg/ffmpeg.go b/core/ffmpeg/ffmpeg.go index 4b782f01c..62a8e13d5 100644 --- a/core/ffmpeg/ffmpeg.go +++ b/core/ffmpeg/ffmpeg.go @@ -171,7 +171,7 @@ func createProbeCommand(cmd string, inputs []string) []string { } func fixCmd(cmd string) []string { - split := strings.Split(cmd, " ") + split := strings.Fields(cmd) cmdPath, _ := ffmpegCmd() for i, s := range split { if s == "ffmpeg" || s == "ffmpeg.exe" { diff --git a/core/ffmpeg/ffmpeg_test.go b/core/ffmpeg/ffmpeg_test.go index 4b8437e2c..7e67a2a6a 100644 --- a/core/ffmpeg/ffmpeg_test.go +++ b/core/ffmpeg/ffmpeg_test.go @@ -27,6 +27,10 @@ var _ = Describe("ffmpeg", func() { args := createFFmpegCommand("ffmpeg -i %s -b:a %bk mp3 -", "/music library/file.mp3", 123, 0) Expect(args).To(Equal([]string{"ffmpeg", "-i", "/music library/file.mp3", "-b:a", "123k", "mp3", "-"})) }) + It("handles extra spaces in the command string", func() { + args := createFFmpegCommand("ffmpeg -i %s -b:a %bk mp3 -", "/music library/file.mp3", 123, 0) + Expect(args).To(Equal([]string{"ffmpeg", "-i", "/music library/file.mp3", "-b:a", "123k", "mp3", "-"})) + }) Context("when command has time offset param", func() { It("creates a valid command line with offset", func() { args := createFFmpegCommand("ffmpeg -i %s -b:a %bk -ss %t mp3 -", "/music library/file.mp3", 123, 456)