Skip to content

Commit

Permalink
REWORK
Browse files Browse the repository at this point in the history
  • Loading branch information
tqk2811 committed Jan 13, 2022
1 parent 88545e7 commit e12cb94
Show file tree
Hide file tree
Showing 643 changed files with 1,598 additions and 7,797 deletions.
3 changes: 0 additions & 3 deletions FFmpegArgs.Autogens/DocLine.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace FFmpegArgs.Autogens
{
internal class DocLine
{
public string LineData { get; set; }
public List<DocLine> ChildLines { get; } = new List<DocLine>();

public override string ToString()
{
return LineData;
}

public static List<DocLine> GetDocLine(List<string> lines)
{
List<DocLine> docLines = new List<DocLine>();
Expand Down
3 changes: 2 additions & 1 deletion FFmpegArgs.Autogens/FFmpegArgs.Autogens.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\FFmpegArgs.Filters\FFmpegArgs.Filters.csproj" />
<ProjectReference Include="..\FFmpegArgs.Filters.Common\FFmpegArgs.Filters.Common.csproj" />
<ProjectReference Include="..\FFmpegArgs\FFmpegArgs.csproj" />
</ItemGroup>

</Project>
101 changes: 14 additions & 87 deletions FFmpegArgs.Autogens/FiltersGen.cs

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions FFmpegArgs.Autogens/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace FFmpegArgs.Autogens
{
internal class Program
Expand All @@ -11,12 +10,10 @@ static void Main(string[] args)
{
var filters = GetDoc("-filters").Skip(8).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.TrimStart()).ToList();
var fulls = DocLine.GetDocLine(GetDoc("-h full").ToList());

FiltersGen.Gen(filters, fulls);
Console.ReadLine();
}


static IEnumerable<string> GetDoc(string arg)
{
ProcessStartInfo processStart = new ProcessStartInfo();
Expand All @@ -32,6 +29,5 @@ static IEnumerable<string> GetDoc(string arg)
}
while (!process.StandardOutput.EndOfStream);
}

}
}
4 changes: 2 additions & 2 deletions FFmpegArgs.Executes/FFmpegArgs.Executes.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--https://docs.microsoft.com/en-us/nuget/reference/nuspec-->
<metadata>
<id>FFmpegArgs.Executes</id>
<version>1.1.1$build$</version>
<version>1.2.0$build$</version>
<description>Executable for FFmpegArgs</description>
<authors>tqk2811</authors>
<projectUrl>https://github.com/tqk2811/FFmpegArgs</projectUrl>
Expand All @@ -12,7 +12,7 @@
<repository type="git" url="https://github.com/tqk2811/FFmpegArgs.git"/>
<dependencies>
<group>
<dependency id="FFmpegArgs" version="[1.1,1.2)"/>
<dependency id="FFmpegArgs" version="[1.2,1.3)"/>
</group>
<group targetFramework="net462">

Expand Down
41 changes: 16 additions & 25 deletions FFmpegArgs.Executes/FFmpegRender.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

namespace FFmpegArgs.Executes
namespace FFmpegArgs.Executes
{
public class FFmpegRender
public class FFmpegRender
{

/// <summary>
///
/// </summary>
public event Action<RenderProgress> OnEncodingProgress;
/// <summary>
///
/// </summary>
public event Action<string> OnOutputDataReceived;

/// <summary>
///
/// </summary>
public FFmpegRenderConfig Config { get; }

internal FFmpegRender(FFmpegRenderConfig config)
{
Config = config;
}

/// <summary>
///
/// </summary>
public string Arguments { get; private set; }

internal void ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if (OnEncodingProgress != null)
Expand All @@ -28,12 +30,10 @@ internal void ErrorDataReceived(object sender, DataReceivedEventArgs e)
if (progress != null) OnEncodingProgress?.Invoke(progress);
}
}

internal void OutputDataReceived(object sender, DataReceivedEventArgs e)
{
OnOutputDataReceived?.Invoke(e?.Data);
}

/// <summary>
///
/// </summary>
Expand All @@ -46,12 +46,10 @@ public static FFmpegRender FromArguments(FFmpegArg ffmpegArg, Action<FFmpegRende
{
if (ffmpegArg == null) throw new ArgumentNullException(nameof(ffmpegArg));
if (config == null) throw new ArgumentNullException(nameof(config));

FFmpegRenderConfig buildConfig = new FFmpegRenderConfig();
config.Invoke(buildConfig);
return FromArguments(ffmpegArg, buildConfig);
}

/// <summary>
///
/// </summary>
Expand All @@ -64,23 +62,19 @@ public static FFmpegRender FromArguments(FFmpegArg ffmpegArg, FFmpegRenderConfig
{
if (ffmpegArg == null) throw new ArgumentNullException(nameof(ffmpegArg));
if (config == null) throw new ArgumentNullException(nameof(config));

FFmpegRender fFmpegBuild = new FFmpegRender(config);
string args = ffmpegArg.GetFullCommandline();
if (config.IsForceUseScript || args.Length > config.ArgumentsMaxLength)
{
string scripts = ffmpegArg.FilterGraph.GetFiltersArgs(true, true);
if(string.IsNullOrWhiteSpace(scripts)) throw new ProcessArgumentOutOfRangeException($"{nameof(FFmpegArg)} argument too long");

if (string.IsNullOrWhiteSpace(scripts)) throw new ProcessArgumentOutOfRangeException($"{nameof(FFmpegArg)} argument too long");
File.WriteAllText(Path.Combine(config.WorkingDirectory, config.FilterScriptName), scripts);
fFmpegBuild.Arguments = ffmpegArg.GetFullCommandlineWithFilterScript(config.FilterScriptName);

if (fFmpegBuild.Arguments.Length > config.ArgumentsMaxLength) throw new ProcessArgumentOutOfRangeException($"{nameof(FFmpegArg)} argument too long");
}
else fFmpegBuild.Arguments = args;
return fFmpegBuild;
}

/// <summary>
///
/// </summary>
Expand All @@ -94,13 +88,11 @@ public static FFmpegRender FromArguments(string commands, FFmpegRenderConfig con
if (string.IsNullOrWhiteSpace(commands)) throw new ArgumentNullException(nameof(commands));
if (config == null) throw new ArgumentNullException(nameof(config));
if (commands.Length > config.ArgumentsMaxLength) throw new ProcessArgumentOutOfRangeException($"{nameof(commands)} too long");

return new FFmpegRender(config)
{
Arguments = commands
};
}

/// <summary>
///
/// </summary>
Expand All @@ -112,8 +104,7 @@ public static FFmpegRender FromArguments(string commands, FFmpegRenderConfig con
public static FFmpegRender FromArguments(string commands, Action<FFmpegRenderConfig> config)
{
if (string.IsNullOrWhiteSpace(commands)) throw new ArgumentNullException(nameof(commands));
if (config == null) throw new ArgumentNullException(nameof(config));

if (config == null) throw new ArgumentNullException(nameof(config));
FFmpegRenderConfig buildConfig = new FFmpegRenderConfig();
config.Invoke(buildConfig);
return FromArguments(commands, buildConfig);
Expand Down
23 changes: 4 additions & 19 deletions FFmpegArgs.Executes/FFmpegRenderConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.IO;

namespace FFmpegArgs.Executes
namespace FFmpegArgs.Executes
{
/// <summary>
///
/// </summary>
public class FFmpegRenderConfig
{
/// <summary>
Expand All @@ -17,18 +17,13 @@ public string FFmpegBinaryPath
else throw new FileNotFoundException(value);
}
}

string _FFmpegBinaryPath = "ffmpeg";



/// <summary>
/// Default: False
/// </summary>
public bool IsForceUseScript { get; set; } = false;



/// <summary>
/// Default: FS.txt
/// </summary>
Expand All @@ -43,15 +38,11 @@ public string FilterScriptName
}
string _FilterScriptName = "FS.txt";



/// <summary>
/// Default: Directory.GetCurrentDirectory()
/// </summary>
public string WorkingDirectory { get; set; } = Directory.GetCurrentDirectory();



/// <summary>
/// Window default: 32766
/// </summary>
Expand All @@ -64,13 +55,9 @@ public int ArgumentsMaxLength
else throw new InvalidDataException($"ArgumentsMaxLength should be > 10");
}
}

int _ArgumentsMaxLength = 32766;





/// <summary>
/// Default: ffmpeg
/// </summary>
Expand All @@ -80,7 +67,6 @@ public FFmpegRenderConfig WithFFmpegBinaryPath(string filePath)
else throw new FileNotFoundException(filePath);
return this;
}

/// <summary>
/// Default: FS.txt
/// </summary>
Expand All @@ -91,7 +77,6 @@ public FFmpegRenderConfig WithFilterScriptName(string scriptName, bool forceUseS
IsForceUseScript = forceUseScript;
return this;
}

/// <summary>
/// Default: Directory.GetCurrentDirectory()
/// </summary>
Expand Down
21 changes: 16 additions & 5 deletions FFmpegArgs.Executes/FFmpegRenderException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
using System;
using System.Collections.Generic;

namespace FFmpegArgs.Executes
namespace FFmpegArgs.Executes
{
public class FFmpegRenderException: Exception
/// <summary>
///
/// </summary>
public class FFmpegRenderException : Exception
{
/// <summary>
///
/// </summary>
public int ExitCode { get; }
/// <summary>
///
/// </summary>
public IEnumerable<string> OutputDatas { get; }
/// <summary>
///
/// </summary>
/// <param name="ExitCode"></param>
/// <param name="outputData"></param>
public FFmpegRenderException(int ExitCode, IEnumerable<string> outputData) : base()
{
this.ExitCode = ExitCode;
Expand Down
Loading

0 comments on commit e12cb94

Please sign in to comment.