-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using LGPL compiled ffmpeg shared for FFmpeg n5.0 from [here](https:/ #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\FFmpeg.AutoGen\FFmpeg.AutoGen.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||
using System; | ||||||
using System.IO; | ||||||
using System.Runtime.InteropServices; | ||||||
|
||||||
namespace FFmpeg.AutoGen.Example | ||||||
{ | ||||||
public class FFmpegBinariesHelper | ||||||
{ | ||||||
internal static void RegisterFFmpegBinaries() | ||||||
{ | ||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||||||
{ | ||||||
var current = Environment.CurrentDirectory; | ||||||
var probe = Path.Combine("FFmpeg", "bin", Environment.Is64BitProcess ? "x64" : "x86"); | ||||||
|
||||||
while (current != null) | ||||||
{ | ||||||
var ffmpegBinaryPath = Path.Combine(current, probe); | ||||||
|
||||||
if (Directory.Exists(ffmpegBinaryPath)) | ||||||
{ | ||||||
Console.WriteLine($"FFmpeg binaries found in: {ffmpegBinaryPath}"); | ||||||
ffmpeg.RootPath = ffmpegBinaryPath; | ||||||
return; | ||||||
} | ||||||
|
||||||
current = Directory.GetParent(current)?.FullName; | ||||||
} | ||||||
} | ||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||||||
ffmpeg.RootPath = "/lib/x86_64-linux-gnu/"; | ||||||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The FFmpeg root path for Linux is hardcoded to "/lib/x86_64-linux-gnu/". This may not be accurate for all Linux distributions. Consider making this path configurable or verifying that the directory exists before setting it. |
||||||
else | ||||||
throw new NotSupportedException(); // fell free add support for platform of your choose | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - throw new NotSupportedException();
+ throw new NotSupportedException("The current platform is not supported. Please add support for it or use a supported platform."); Committable suggestion
Suggested change
|
||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||||||||||||||||||
using System; | ||||||||||||||||||||||
using System.Runtime.InteropServices; | ||||||||||||||||||||||
|
||||||||||||||||||||||
namespace FFmpeg.AutoGen.Example | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
internal static class FFmpegHelper | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
public static unsafe string av_strerror(int error) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
var bufferSize = 1024; | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider defining the buffer size as a constant to improve code readability and maintainability. - var bufferSize = 1024;
+ const int ErrorBufferSize = 1024;
+ var bufferSize = ErrorBufferSize; Committable suggestion
Suggested change
|
||||||||||||||||||||||
var buffer = stackalloc byte[bufferSize]; | ||||||||||||||||||||||
ffmpeg.av_strerror(error, buffer, (ulong) bufferSize); | ||||||||||||||||||||||
var message = Marshal.PtrToStringAnsi((IntPtr) buffer); | ||||||||||||||||||||||
return message; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
public static int ThrowExceptionIfError(this int error) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
if (error < 0) throw new ApplicationException(av_strerror(error)); | ||||||||||||||||||||||
return error; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+17
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method name - public static int ThrowExceptionIfError(this int error)
+ public static int EnsureSuccessOrThrow(this int error)
{
if (error < 0) throw new FFmpegException(av_strerror(error));
return error;
} Committable suggestion
Suggested change
|
||||||||||||||||||||||
} | ||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace FFmpeg.AutoGen.Example | ||
{ | ||
public class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
FFmpegBinariesHelper.RegisterFFmpegBinaries(); | ||
var transcoding = new Transcoding(); | ||
transcoding.main(args.Length, args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method name
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no error handling for exceptions that might be thrown by |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search for FFmpeg binaries on Windows could potentially traverse up to the root of the file system. Consider adding a limit to the number of directory levels to traverse to prevent excessive searching and to fail early if the binaries are not found in an expected location.