forked from Ruslan-B/FFmpeg.AutoGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using LGPL compiled ffmpeg shared for FFmpeg n5.0 from [here](https:/…
…/github.com/BtbN/FFmpeg-Builds/releases) * specifically - ffmpeg-n5.0-latest-win64-lgpl-shared-5.0.zip targets openH264 rather than the GPL x264 encoder modifies FFmpeg.AutoGen.Example to output an MP4 rather than .h264 file by way of: * adding AVFormatContext and AVStream * using ffmpeg.avio_open to create / write the file instead of System.IO.xxx * writing a header and trailer * using ffmpeg.av_interleaved_write_frame() includes a somewhat mangled but updated and somewhat working version of the Transcoding gist shared by Ruslan-B
- Loading branch information
1 parent
24da0e7
commit d6af667
Showing
26 changed files
with
999 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
FFmpeg.AutoGen.Example.Transcoding/FFmpeg.AutoGen.Example.Transcoding.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
36 changes: 36 additions & 0 deletions
36
FFmpeg.AutoGen.Example.Transcoding/FFmpegBinariesHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/"; | ||
else | ||
throw new NotSupportedException(); // fell free add support for platform of your choose | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.