From 50bb1630b88007a57673bb0c3312225b57b5fa32 Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 10 Oct 2020 17:48:40 +0100 Subject: [PATCH] Code no longer makes assumption about source filename format - #7 --- remux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/remux.go b/remux.go index 9c28072..dcbd9bd 100644 --- a/remux.go +++ b/remux.go @@ -102,7 +102,12 @@ func RemuxCLI(files []string, extractAudio bool, extractVideo bool, forceRate in // Strip the unixtime from the filename, we'll replace with the start timecode of the partition baseFilename := strings.TrimSuffix(path.Base(ubvFile), path.Ext(ubvFile)) - baseFilename = baseFilename[0:strings.LastIndex(baseFilename, "_")] + + // If the filename contains underscores, assume it's a Unifi Protect Filename + // and drop the final component. + if strings.Contains(baseFilename, "_") { + baseFilename = baseFilename[0:strings.LastIndex(baseFilename, "_")] + } basename := outputFolder + "/" + baseFilename + "_" + strings.ReplaceAll(getStartTimecode(partition).Format(time.RFC3339), ":", ".")