Refactor code formatting and improve readability: standardize line breaks and indentation across various endpoint files, enhancing code clarity and maintainability. Update package version formatting in Directory.Packages.props for consistency.
This commit is contained in:
@@ -60,11 +60,15 @@ public sealed class FfmpegBumperRenderer(
|
||||
|
||||
var playlist = Path.Combine(assetDir, "index.m3u8");
|
||||
if (!File.Exists(playlist))
|
||||
throw new InvalidOperationException("ffmpeg не создал плейлист заставки index.m3u8.");
|
||||
throw new InvalidOperationException(
|
||||
"ffmpeg не создал плейлист заставки index.m3u8."
|
||||
);
|
||||
|
||||
var segmentCount = Directory.GetFiles(assetDir, "seg*.ts").Length;
|
||||
if (segmentCount == 0)
|
||||
throw new InvalidOperationException("ffmpeg не создал ни одного сегмента заставки.");
|
||||
throw new InvalidOperationException(
|
||||
"ffmpeg не создал ни одного сегмента заставки."
|
||||
);
|
||||
|
||||
return new BumperRenderResult(
|
||||
TimeSpan.FromSeconds(target),
|
||||
@@ -168,17 +172,33 @@ public sealed class FfmpegBumperRenderer(
|
||||
var line2Size = FitSize(spec.FreeLine2, titleSize, textWidth);
|
||||
var line1Y = (int)(h * 0.40);
|
||||
var line2Y = line1Y + (int)(line2Size * 1.2);
|
||||
vchain.Append(',').Append(DrawTitle(font, nowFile, spec.AccentColor, line1Size, line1Y, 0.2));
|
||||
vchain.Append(',').Append(DrawTitle(font, nextFile, spec.TextColor, line2Size, line2Y, 0.5));
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(DrawTitle(font, nowFile, spec.AccentColor, line1Size, line1Y, 0.2));
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(DrawTitle(font, nextFile, spec.TextColor, line2Size, line2Y, 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
var nowSize = FitSize(spec.NowTitle, titleSize, textWidth);
|
||||
var nextSize = FitSize(spec.NextTitle, titleSize, textWidth);
|
||||
vchain.Append(',').Append(DrawLabel(font, spec.NowLabel, spec.AccentColor, labelSize, nowLabelY, 0.2));
|
||||
vchain.Append(',').Append(DrawTitle(font, nowFile, spec.TextColor, nowSize, nowTitleY, 0.3));
|
||||
vchain.Append(',').Append(DrawLabel(font, spec.NextLabel, spec.AccentColor, labelSize, nextLabelY, 1.0));
|
||||
vchain.Append(',').Append(DrawTitle(font, nextFile, spec.TextColor, nextSize, nextTitleY, 1.1));
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(
|
||||
DrawLabel(font, spec.NowLabel, spec.AccentColor, labelSize, nowLabelY, 0.2)
|
||||
);
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(DrawTitle(font, nowFile, spec.TextColor, nowSize, nowTitleY, 0.3));
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(
|
||||
DrawLabel(font, spec.NextLabel, spec.AccentColor, labelSize, nextLabelY, 1.0)
|
||||
);
|
||||
vchain
|
||||
.Append(',')
|
||||
.Append(DrawTitle(font, nextFile, spec.TextColor, nextSize, nextTitleY, 1.1));
|
||||
}
|
||||
vchain.Append("[v]");
|
||||
|
||||
@@ -186,28 +206,47 @@ public sealed class FfmpegBumperRenderer(
|
||||
|
||||
var args = new List<string> { "-hide_banner", "-nostdin", "-y" };
|
||||
args.AddRange(inputs);
|
||||
args.AddRange(
|
||||
[
|
||||
"-filter_complex", filterComplex,
|
||||
"-map", "[v]",
|
||||
"-map", "[a]",
|
||||
"-threads", _media.TranscodeThreads.ToString(CultureInfo.InvariantCulture),
|
||||
"-c:v", "libx264",
|
||||
"-preset", "veryfast",
|
||||
"-crf", "21",
|
||||
"-pix_fmt", "yuv420p",
|
||||
"-force_key_frames", $"expr:gte(t,n_forced*{seg.ToString(CultureInfo.InvariantCulture)})",
|
||||
"-sc_threshold", "0",
|
||||
"-c:a", "aac",
|
||||
"-b:a", "128k",
|
||||
"-ac", "2",
|
||||
"-ar", "48000",
|
||||
"-t", Fmt(target),
|
||||
"-f", "hls",
|
||||
"-hls_time", seg.ToString(CultureInfo.InvariantCulture),
|
||||
"-hls_playlist_type", "vod",
|
||||
"-hls_list_size", "0",
|
||||
"-hls_segment_filename", Path.Combine(assetDir, "seg%05d.ts"),
|
||||
args.AddRange([
|
||||
"-filter_complex",
|
||||
filterComplex,
|
||||
"-map",
|
||||
"[v]",
|
||||
"-map",
|
||||
"[a]",
|
||||
"-threads",
|
||||
_media.TranscodeThreads.ToString(CultureInfo.InvariantCulture),
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"veryfast",
|
||||
"-crf",
|
||||
"21",
|
||||
"-pix_fmt",
|
||||
"yuv420p",
|
||||
"-force_key_frames",
|
||||
$"expr:gte(t,n_forced*{seg.ToString(CultureInfo.InvariantCulture)})",
|
||||
"-sc_threshold",
|
||||
"0",
|
||||
"-c:a",
|
||||
"aac",
|
||||
"-b:a",
|
||||
"128k",
|
||||
"-ac",
|
||||
"2",
|
||||
"-ar",
|
||||
"48000",
|
||||
"-t",
|
||||
Fmt(target),
|
||||
"-f",
|
||||
"hls",
|
||||
"-hls_time",
|
||||
seg.ToString(CultureInfo.InvariantCulture),
|
||||
"-hls_playlist_type",
|
||||
"vod",
|
||||
"-hls_list_size",
|
||||
"0",
|
||||
"-hls_segment_filename",
|
||||
Path.Combine(assetDir, "seg%05d.ts"),
|
||||
Path.Combine(assetDir, "index.m3u8"),
|
||||
]);
|
||||
return args;
|
||||
@@ -261,8 +300,7 @@ public sealed class FfmpegBumperRenderer(
|
||||
|
||||
/// <summary>Экранирование пути для значения опции фильтра (Windows-разделители → прямые слэши,
|
||||
/// двоеточие экранируется). На Linux (контейнере) — фактически no-op.</summary>
|
||||
private static string EscapePath(string path) =>
|
||||
path.Replace('\\', '/').Replace(":", "\\:");
|
||||
private static string EscapePath(string path) => path.Replace('\\', '/').Replace(":", "\\:");
|
||||
|
||||
/// <summary>Экранирование литерального текста подписи внутри значения опции drawtext.</summary>
|
||||
private static string EscapeText(string text) =>
|
||||
|
||||
Reference in New Issue
Block a user