Skip to content

Commit fe1a128

Browse files
committed
Refactored & improved VBR/2pass
1 parent b129c75 commit fe1a128

32 files changed

+135
-107
lines changed

ff-utils-winforms/Data/Codecs/Audio/Aac.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class Aac : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
string bitrate = encArgs.ContainsKey("bitrate") ? encArgs["bitrate"] : "128k";
2930
string channels = encArgs.ContainsKey("ac") ? encArgs["ac"] : "2";

ff-utils-winforms/Data/Codecs/Audio/CopyAudio.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class CopyAudio : IEncoder
2121
public string QInfo { get; } = "Does not alter quality.";
2222
public string PresetInfo { get; }
2323

24-
public bool DoesNotEncode { get; } = true;
24+
public bool SupportsTwoPass { get; } = false;
25+
public bool DoesNotEncode { get; } = true;
2526
public bool IsFixedFormat { get; } = false;
2627
public bool IsSequence { get; } = false;
2728

28-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
29+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2930
{
3031
return new CodecArgs($"-c:a copy");
3132
}

ff-utils-winforms/Data/Codecs/Audio/Flac.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class Flac : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
string channels = encArgs.ContainsKey("ac") ? encArgs["ac"] : "2";
2930
return new CodecArgs($"-c:a flac -ac {channels}");

ff-utils-winforms/Data/Codecs/Audio/Mp3.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class Mp3 : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
string bitrate = encArgs.ContainsKey("bitrate") ? encArgs["bitrate"] : "320k";
2930
string channels = encArgs.ContainsKey("ac") ? encArgs["ac"] : "2";

ff-utils-winforms/Data/Codecs/Audio/Opus.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class Opus : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
string bitrate = encArgs.ContainsKey("bitrate") ? encArgs["bitrate"] : "96k";
2930
string channels = encArgs.ContainsKey("ac") ? encArgs["ac"] : "2";

ff-utils-winforms/Data/Codecs/Audio/StripAudio.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class StripAudio : IEncoder
2121
public string QInfo { get; }
2222
public string PresetInfo { get; }
2323

24-
public bool DoesNotEncode { get; } = true;
24+
public bool SupportsTwoPass { get; } = false;
25+
public bool DoesNotEncode { get; } = true;
2526
public bool IsFixedFormat { get; } = false;
2627
public bool IsSequence { get; } = false;
2728

28-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
29+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2930
{
3031
return new CodecArgs($"-an");
3132
}

ff-utils-winforms/Data/Codecs/IEncoder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Nmkoder.Data.Codecs
88
{
9+
public enum Pass { OneOfOne, OneOfTwo, TwoOfTwo }
10+
911
interface IEncoder
1012
{
1113
Streams.Stream.StreamType Type { get; }
@@ -21,10 +23,11 @@ interface IEncoder
2123
string QInfo { get; }
2224
string PresetInfo { get; }
2325

26+
bool SupportsTwoPass { get; }
2427
bool DoesNotEncode { get; }
2528
bool IsFixedFormat { get; }
2629
bool IsSequence { get; }
2730

28-
CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null);
31+
CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null);
2932
}
3033
}

ff-utils-winforms/Data/Codecs/Subs/CopySubs.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class CopySubs : IEncoder
2121
public string QInfo { get; }
2222
public string PresetInfo { get; }
2323

24-
public bool DoesNotEncode { get; } = true;
24+
public bool SupportsTwoPass { get; } = false;
25+
public bool DoesNotEncode { get; } = true;
2526
public bool IsFixedFormat { get; } = false;
2627
public bool IsSequence { get; } = false;
2728

28-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
29+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2930
{
3031
return new CodecArgs($"-c:s copy");
3132
}

ff-utils-winforms/Data/Codecs/Subs/MovText.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class MovText : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
return new CodecArgs($"-c:s mov_text");
2930
}

ff-utils-winforms/Data/Codecs/Subs/Srt.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class Srt : IEncoder
1919
public string QInfo { get; }
2020
public string PresetInfo { get; }
2121

22-
public bool DoesNotEncode { get; } = false;
22+
public bool SupportsTwoPass { get; } = false;
23+
public bool DoesNotEncode { get; } = false;
2324
public bool IsFixedFormat { get; } = false;
2425
public bool IsSequence { get; } = false;
2526

26-
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null)
27+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, Pass pass = Pass.OneOfOne, MediaFile mediaFile = null)
2728
{
2829
return new CodecArgs($"-c:s srt");
2930
}

0 commit comments

Comments
 (0)