Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/SIPSorceryMedia.FFmpeg/FFmpegCameraSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public unsafe FFmpegCameraSource(Camera camera)
string inputFormat = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dshow"
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "v4l2"
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "avfoundation"
: throw new NotSupportedException($"Cannot find adequate input format" +
$" - OSArchitecture:[{RuntimeInformation.OSArchitecture}]" +
$" - OSDescription:[{RuntimeInformation.OSDescription}]");
: throw new NotSupportedException($"Cannot find adequate input format - OSArchitecture:[{RuntimeInformation.OSArchitecture}] - OSDescription:[{RuntimeInformation.OSDescription}]");

var _aVInputFormat = ffmpeg.av_find_input_format(inputFormat);

Expand Down Expand Up @@ -126,7 +124,7 @@ public bool RestrictCameraOptions(Func<Dictionary<string, string>, bool> optFilt
);

if (filtered is null)
logger.LogWarning($"No camera/input device options to be used.");
logger.LogWarning("No camera/input device options to be used.");

return SetCameraDeviceOptions(filtered);
}
Expand Down
6 changes: 3 additions & 3 deletions src/SIPSorceryMedia.FFmpeg/FFmpegScreenSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public unsafe FFmpegScreenSource(string path, Rectangle rect, int frameRate = 20
{
["offset_x"] = rect.X.ToString(),
["offset_y"] = rect.Y.ToString(),
["video_size"] = $"{rect.Width.ToString()}X{rect.Height.ToString()}",
["video_size"] = $"{rect.Width}X{rect.Height}",
["framerate"] = frameRate.ToString()
};
}
Expand All @@ -37,7 +37,7 @@ public unsafe FFmpegScreenSource(string path, Rectangle rect, int frameRate = 20
inputFormat = "avfoundation";
options = new Dictionary<string, string>()
{
["vf"] = $"crop={rect.Width.ToString()}:{rect.Height.ToString()}:{rect.X.ToString()}:{rect.Y.ToString()}",
["vf"] = $"crop={rect.Width}:{rect.Height}:{rect.X}:{rect.Y}",
["framerate"] = frameRate.ToString()
};
}
Expand All @@ -47,7 +47,7 @@ public unsafe FFmpegScreenSource(string path, Rectangle rect, int frameRate = 20
//https://superuser.com/questions/1562228/how-to-specify-the-size-to-record-the-screen-with-ffmpeg
options = new Dictionary<string, string>()
{
["video_size"] = $"{rect.Width.ToString()}X{rect.Height.ToString()}",
["video_size"] = $"{rect.Width}X{rect.Height}",
["grab_x"] = rect.X.ToString(),
["grab_y"] = rect.Y.ToString(),
["framerate"] = frameRate.ToString()
Expand Down
15 changes: 6 additions & 9 deletions src/SIPSorceryMedia.FFmpeg/FfmpegInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void Initialise(FfmpegLogLevelEnum? logLevel = null, String? libPa

RegisterFFmpegBinaries(libPath);

logger.LogInformation($"FFmpeg version info: {ffmpeg.av_version_info()}");
logger.LogInformation("FFmpeg version info: {VersionInfo}", ffmpeg.av_version_info());

if (logLevel.HasValue)
{
Expand All @@ -105,10 +105,7 @@ internal static void SetFFmpegBinariesPath(string path)
catch (Exception e)
{
throw new DllNotFoundException(
"Check the dependencies of FFmpeg libraries and make sure they are " +
"searchable by the operating system's library loader."
+ "\nOn linux you can use 'ldd' & 'strace'."
+ "\nOn Windows you can use 'Dependencies'."
$"Check the dependencies of FFmpeg libraries and make sure they are searchable by the operating system's library loader.\nOn linux you can use 'ldd' & 'strace'.\nOn Windows you can use 'Dependencies'."
, e);
}
}
Expand All @@ -124,12 +121,12 @@ internal static void RegisterFFmpegBinaries(String? libPath = null)
string ffmpegExecutable = "ffmpeg";
string? path = Environment.GetEnvironmentVariable("PATH")?
.Split([';'], StringSplitOptions.RemoveEmptyEntries)
.Where(s => File.Exists(Path.Combine(s, ffmpegExecutable)) || File.Exists(Path.Combine(s, ffmpegExecutable + ".exe")))
.Where(s => File.Exists(Path.Combine(s, ffmpegExecutable)) || File.Exists(Path.Combine(s, $"{ffmpegExecutable}.exe")))
.FirstOrDefault();

if (path != null)
{
logger.LogInformation($"FFmpeg binaries found in system path at: {path}");
logger.LogInformation("FFmpeg binaries found in system path at: {Path}", path);
SetFFmpegBinariesPath(path);
return;
}
Expand All @@ -142,7 +139,7 @@ internal static void RegisterFFmpegBinaries(String? libPath = null)
var ffmpegBinaryPath = Path.Combine(current, probe);
if (Directory.Exists(ffmpegBinaryPath))
{
logger.LogInformation($"FFmpeg binaries found in: {ffmpegBinaryPath}");
logger.LogInformation("FFmpeg binaries found in: {Path}", ffmpegBinaryPath);
SetFFmpegBinariesPath(ffmpegBinaryPath);
return;
}
Expand All @@ -154,7 +151,7 @@ internal static void RegisterFFmpegBinaries(String? libPath = null)
{
if (Directory.Exists(libPath))
{
logger.LogInformation($"FFmpeg binaries path set to: {libPath}");
logger.LogInformation("FFmpeg binaries path set to: {Path}", libPath);
SetFFmpegBinariesPath(libPath);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SIPSorceryMedia.FFmpeg/Interop/MacOs/AvFoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static unsafe String GetAvFoundationLogsAboutDevicesList()
{
index = ln.IndexOf("]");
string name = ln.Substring(index + 2);
string path = ln.Substring(1, index - 1) + ":";
string path = $"{ln.Substring(1, index - 1)}:";

Monitor monitor = new Monitor
{
Expand Down Expand Up @@ -149,7 +149,7 @@ private static unsafe String GetAvFoundationLogsAboutDevicesList()
{
index = ln.IndexOf("]");
string name = ln.Substring(index+2);
string path = ln.Substring(1, index - 1) + ":";
string path = $"{ln.Substring(1, index - 1)}:";

Camera camera = new Camera
{
Expand Down
Loading