From 6c97ad6a8f1af22f0dcca5095d743ee7c17f097a Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:09:04 -0600 Subject: [PATCH] fix mpegts script on windows --- ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs | 2 +- ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs | 4 ++-- ErsatzTV/ErsatzTV.csproj | 1 + ErsatzTV/Resources/Scripts/MpegTs/mpegts.yml | 1 + ErsatzTV/Resources/Scripts/MpegTs/run.bat | 3 +++ ErsatzTV/Services/RunOnce/ResourceExtractorService.cs | 6 ++++++ 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 ErsatzTV/Resources/Scripts/MpegTs/run.bat diff --git a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs index e39e74a17..b64e10f3a 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs @@ -847,7 +847,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService // TODO: save reports? string defaultScript = await _configElementRepository .GetValue(ConfigElementKey.FFmpegDefaultMpegTsScript, cancellationToken) - .IfNoneAsync("Default"); + .IfNoneAsync("default"); List allScripts = _mpegTsScriptService.GetScripts(); Option maybeScript = Optional(allScripts.Find(s => s.Id == defaultScript)); foreach (var script in maybeScript) diff --git a/ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs b/ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs index a9d32514b..f17a67efd 100644 --- a/ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs +++ b/ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs @@ -60,9 +60,9 @@ public class MpegTsScriptService( ffmpegPath); foreach (string finalScript in maybeScript) { - string fileName = tempFilePool.GetNextTempFile(TempFileCategory.MpegTsScript); + var fileName = $"{tempFilePool.GetNextTempFile(TempFileCategory.MpegTsScript)}.bat"; await File.WriteAllTextAsync(fileName, finalScript); - return Cli.Wrap("pwsh").WithArguments(["-File", fileName]); + return Cli.Wrap(fileName); } } } diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 8292378eb..c7f006b64 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -83,6 +83,7 @@ + diff --git a/ErsatzTV/Resources/Scripts/MpegTs/mpegts.yml b/ErsatzTV/Resources/Scripts/MpegTs/mpegts.yml index d7e93dd3c..e3c66faf2 100644 --- a/ErsatzTV/Resources/Scripts/MpegTs/mpegts.yml +++ b/ErsatzTV/Resources/Scripts/MpegTs/mpegts.yml @@ -1,2 +1,3 @@ name: "Default" linux_script: "run.sh" +windows_script: "run.bat" diff --git a/ErsatzTV/Resources/Scripts/MpegTs/run.bat b/ErsatzTV/Resources/Scripts/MpegTs/run.bat new file mode 100644 index 000000000..747b9d645 --- /dev/null +++ b/ErsatzTV/Resources/Scripts/MpegTs/run.bat @@ -0,0 +1,3 @@ +@echo off + +"{{ FFmpegPath }}" -nostdin -threads 1 -hide_banner -loglevel error -nostats -fflags +genpts+discardcorrupt+igndts -readrate 1.0 -i "{{ HlsUrl }}" -map 0 -c copy -metadata service_provider="ErsatzTV" -metadata service_name="{{ ChannelName }}" -f mpegts pipe:1 diff --git a/ErsatzTV/Services/RunOnce/ResourceExtractorService.cs b/ErsatzTV/Services/RunOnce/ResourceExtractorService.cs index e95f9075f..131723b23 100644 --- a/ErsatzTV/Services/RunOnce/ResourceExtractorService.cs +++ b/ErsatzTV/Services/RunOnce/ResourceExtractorService.cs @@ -110,6 +110,12 @@ public class ResourceExtractorService : BackgroundService FileSystemLayout.DefaultMpegTsScriptFolder, stoppingToken); + await ExtractMpegTsScriptResource( + assembly, + "run.bat", + FileSystemLayout.DefaultMpegTsScriptFolder, + stoppingToken); + await ExtractMpegTsScriptResource( assembly, "mpegts.yml",