Skip to content

Commit

Permalink
feat: expose stream index
Browse files Browse the repository at this point in the history
  • Loading branch information
josephnhtam committed Sep 18, 2024
1 parent 122f9ac commit fdbd273
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
33 changes: 33 additions & 0 deletions samples/LiveStreamingServerNet.AdaptiveHlsDemo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LiveStreamingServerNet.StreamProcessor.AspNetCore.Installer;
using LiveStreamingServerNet.StreamProcessor.Contracts;
using LiveStreamingServerNet.StreamProcessor.Hls.Configurations;
using LiveStreamingServerNet.StreamProcessor.Installer;
using LiveStreamingServerNet.StreamProcessor.Utilities;
using LiveStreamingServerNet.Utilities.Contracts;
Expand Down Expand Up @@ -51,6 +52,38 @@ private static IServiceCollection AddLiveStreamingServer(this IServiceCollection
options.FFmpegPath = ExecutableFinder.FindExecutableFromPATH("ffmpeg")!;
options.FFprobePath = ExecutableFinder.FindExecutableFromPATH("ffprobe")!;
options.DownsamplingFilters =
[
new DownsamplingFilter(
Name: "360p",
Height: 360,
MaxVideoBitrate: "600k",
MaxAudioBitrate: "64k"
),
new DownsamplingFilter(
Name: "480p",
Height: 480,
MaxVideoBitrate: "1500k",
MaxAudioBitrate: "128k"
),
new DownsamplingFilter(
Name: "720p",
Height: 720,
MaxVideoBitrate: "3000k",
MaxAudioBitrate: "256k"
),
new DownsamplingFilter(
Name: "720p_rotated",
Height: 720,
MaxVideoBitrate: "3000k",
MaxAudioBitrate: "256k",
ExtraArguments: (streamIndex) => $"-filter:v:{streamIndex} transpose=1"
),
];
// Hardware acceleration
// options.VideoDecodingArguments = "-hwaccel auto -c:v h264_cuvid";
// options.VideoEncodingArguments = "-c:v h264_nvenc -g 30";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ public record HlsOptions(
string? ExtraArguments = null
);

public record DownsamplingFilter(string Name, int Height, string MaxVideoBitrate, string MaxAudioBitrate, string? ExtraArguments = null);
public delegate string ExtraFilterArguments(int streamIndex);
public record DownsamplingFilter(string Name, int Height, string MaxVideoBitrate, string MaxAudioBitrate, ExtraFilterArguments? ExtraArguments = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static void AddDownsamplingFilters(IList<DownsamplingFilter> downsamplin
arguments.Add($"-maxrate:v:{i} {filter.MaxVideoBitrate}");
arguments.Add($"-b:a:{i} {filter.MaxAudioBitrate}");

AddOptionalArgument(arguments, filter.ExtraArguments);
AddOptionalArgument(arguments, filter.ExtraArguments?.Invoke(i));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageTags>live-streaming;rtmp;transmuxer;transcoder;hls;dash</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Version>0.14.2</Version>
<Version>0.14.3</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down

0 comments on commit fdbd273

Please sign in to comment.