Skip to content

Commit

Permalink
[skip ci] metdata in sample"
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias.haimerl committed Nov 20, 2018
1 parent 3707dbd commit 2724d3c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 79 deletions.
35 changes: 0 additions & 35 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

46 changes: 31 additions & 15 deletions samples/FFmpeg.NET.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FFmpeg.NET.Events;
using System;
using System.Diagnostics;
using System.Threading.Tasks;

namespace FFmpeg.NET.Sample
Expand All @@ -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);
Expand All @@ -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);
}
}
18 changes: 6 additions & 12 deletions src/FFmpeg.NET/MetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -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}";
}
}
}

0 comments on commit 2724d3c

Please sign in to comment.