From 2724d3c92b1c87189caacc661de1b093baa5ef56 Mon Sep 17 00:00:00 2001 From: "tobias.haimerl" Date: Tue, 20 Nov 2018 13:18:57 +0100 Subject: [PATCH] [skip ci] metdata in sample" --- .github/ISSUE_TEMPLATE/bug_report.md | 35 ----------------- .github/ISSUE_TEMPLATE/feature_request.md | 17 --------- samples/FFmpeg.NET.Sample/Program.cs | 46 +++++++++++++++-------- src/FFmpeg.NET/MetaData.cs | 18 +++------ 4 files changed, 37 insertions(+), 79 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index b735373..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 066b2d9..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/samples/FFmpeg.NET.Sample/Program.cs b/samples/FFmpeg.NET.Sample/Program.cs index 52064e3..8d44d06 100644 --- a/samples/FFmpeg.NET.Sample/Program.cs +++ b/samples/FFmpeg.NET.Sample/Program.cs @@ -1,5 +1,6 @@ using FFmpeg.NET.Events; using System; +using System.Diagnostics; using System.Threading.Tasks; namespace FFmpeg.NET.Sample @@ -8,21 +9,36 @@ internal class Program { private static async Task Main(string[] args) { - var inputFile = new MediaFile(@"..\..\..\..\..\tests\FFmpeg.NET.Tests\MediaFiles\SampleVideo_1280x720_1mb.mp4"); - var outputFile = new MediaFile(@"output.mkv"); + try + { + var inputFile = new MediaFile(@"..\..\..\..\..\tests\FFmpeg.NET.Tests\MediaFiles\SampleVideo_1280x720_1mb.mp4"); + var outputFile = new MediaFile(@"output.mkv"); - var ffmpeg = new Engine.FFmpeg(@"..\..\..\..\..\lib\ffmpeg\v4\ffmpeg.exe"); - ffmpeg.Progress += OnProgress; - ffmpeg.Data += OnData; - ffmpeg.Error += OnError; - ffmpeg.Complete += OnComplete; - await ffmpeg.ConvertAsync(inputFile, outputFile); - Console.ReadLine(); + var ffmpeg = new Engine.FFmpeg(@"..\..\..\..\..\lib\ffmpeg\v4\ffmpeg.exe"); + ffmpeg.Progress += OnProgress; + ffmpeg.Data += OnData; + ffmpeg.Error += OnError; + ffmpeg.Complete += OnComplete; + var output = await ffmpeg.ConvertAsync(inputFile, outputFile); + var metadata = await ffmpeg.GetMetaDataAsync(output); + + Console.WriteLine(metadata.FileInfo.FullName); + Console.WriteLine(metadata); + } + catch (Exception exc) + { + Console.WriteLine(exc); + } + finally + { + Console.WriteLine("Press any key to exit..."); + Console.ReadKey(); + } } private static void OnProgress(object sender, ConversionProgressEventArgs e) { - Console.WriteLine("[{0} => {1}]", e.Input.FileInfo.Name, e.Output.FileInfo.Name); + Console.WriteLine("[{0} => {1}]", e.Input.FileInfo.Name, e.Output?.FileInfo.Name); Console.WriteLine("Bitrate: {0}", e.Bitrate); Console.WriteLine("Fps: {0}", e.Fps); Console.WriteLine("Frame: {0}", e.Frame); @@ -32,12 +48,12 @@ private static void OnProgress(object sender, ConversionProgressEventArgs e) } private static void OnData(object sender, ConversionDataEventArgs e) - => Console.WriteLine("[{0} => {1}]: {2}", e.Input.FileInfo.Name, e.Output.FileInfo.Name, e.Data); + => Console.WriteLine("[{0} => {1}]: {2}", e.Input.FileInfo.Name, e.Output?.FileInfo.Name, e.Data); - private static void OnComplete(object sender, ConversionCompleteEventArgs e) - => Console.WriteLine("Completed conversion from {0} to {1}", e.Input.FileInfo.FullName, e.Output.FileInfo.FullName); + private static void OnComplete(object sender, ConversionCompleteEventArgs e) + => Console.WriteLine("Completed conversion from {0} to {1}", e.Input.FileInfo.FullName, e.Output?.FileInfo.FullName); - private static void OnError(object sender, ConversionErrorEventArgs e) - => Console.WriteLine("[{0} => {1}]: Error: {2}\n{3}", e.Input.FileInfo.Name, e.Output.FileInfo.Name, e.Exception.ExitCode, e.Exception.InnerException); + private static void OnError(object sender, ConversionErrorEventArgs e) + => Console.WriteLine("[{0} => {1}]: Error: {2}\n{3}", e.Input.FileInfo.Name, e.Output?.FileInfo.Name, e.Exception.ExitCode, e.Exception.InnerException); } } diff --git a/src/FFmpeg.NET/MetaData.cs b/src/FFmpeg.NET/MetaData.cs index fc41559..f778332 100644 --- a/src/FFmpeg.NET/MetaData.cs +++ b/src/FFmpeg.NET/MetaData.cs @@ -14,10 +14,8 @@ internal MetaData() public Audio AudioData { get; internal set; } public FileInfo FileInfo { get; internal set; } - public override string ToString() - { - return $"Duration: {Duration}\nVideo MetaData:\n{VideoData}\nAudio MetaData:\n{AudioData}"; - } + public override string ToString() + => $"Duration: {Duration}\nVideo MetaData:\n{VideoData}\nAudio MetaData:\n{AudioData}"; public class Video { @@ -31,10 +29,8 @@ internal Video() public int? BitRateKbs { get; internal set; } public double Fps { get; internal set; } - public override string ToString() - { - return $"Format: {Format}\nColorModel: {ColorModel}\nFrameSize: {FrameSize}\nBitRateKbs: {BitRateKbs}\nFps: {Fps}"; - } + public override string ToString() + => $"Format: {Format}\nColorModel: {ColorModel}\nFrameSize: {FrameSize}\nBitRateKbs: {BitRateKbs}\nFps: {Fps}"; } public class Audio @@ -48,10 +44,8 @@ internal Audio() public string ChannelOutput { get; internal set; } public int BitRateKbs { get; internal set; } - public override string ToString() - { - return $"Format: {Format}\nSampleRate: {SampleRate}\nChannelOuput: {ChannelOutput}\nBitRateKbs: {BitRateKbs}"; - } + public override string ToString() + => $"Format: {Format}\nSampleRate: {SampleRate}\nChannelOuput: {ChannelOutput}\nBitRateKbs: {BitRateKbs}"; } } } \ No newline at end of file