mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-01-18 20:46:43 +00:00
Fixed merge & implemented aax mode
This commit is contained in:
parent
499d03f710
commit
f42faa4f26
4 changed files with 48 additions and 7 deletions
|
@ -101,5 +101,13 @@ public void Audible_Aaxc_Test()
|
|||
var arg = new AudibleEncryptionKeyArgument("123", "456");
|
||||
arg.Text.Should().Be($"-audible_key 123 -audible_iv 456");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void Audible_Aax_Test()
|
||||
{
|
||||
var arg = new AudibleEncryptionKeyArgument("62689101");
|
||||
arg.Text.Should().Be($"-activation_bytes 62689101");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,27 @@
|
|||
{
|
||||
public class AudibleEncryptionKeyArgument : IArgument
|
||||
{
|
||||
private readonly bool _aaxcMode;
|
||||
|
||||
private readonly string _key;
|
||||
private readonly string _iv;
|
||||
|
||||
private readonly string _activationBytes;
|
||||
|
||||
|
||||
public AudibleEncryptionKeyArgument(string activationBytes)
|
||||
{
|
||||
_activationBytes = activationBytes;
|
||||
}
|
||||
|
||||
public AudibleEncryptionKeyArgument(string key, string iv)
|
||||
{
|
||||
_aaxcMode = true;
|
||||
|
||||
_key = key;
|
||||
_iv = iv;
|
||||
}
|
||||
|
||||
public string Text => $"-audible_key {_key} -audible_iv {_iv}";
|
||||
public string Text => _aaxcMode ? $"-audible_key {_key} -audible_iv {_iv}" : $"-activation_bytes {_activationBytes}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using FFMpegCore.Extend;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -10,8 +13,10 @@ public class MapMetadataArgument : IInputArgument, IDynamicArgument
|
|||
{
|
||||
private readonly int? _inputIndex;
|
||||
|
||||
public string Text => GetText(null);
|
||||
|
||||
/// <summary>
|
||||
/// Null means it takes the last input used befroe this argument
|
||||
/// Null means it takes the last input used before this argument
|
||||
/// </summary>
|
||||
/// <param name="inputIndex"></param>
|
||||
public MapMetadataArgument(int? inputIndex = null)
|
||||
|
@ -19,15 +24,28 @@ public MapMetadataArgument(int? inputIndex = null)
|
|||
_inputIndex = inputIndex;
|
||||
}
|
||||
|
||||
public string Text => GetText(null);
|
||||
|
||||
public string GetText(StringBuilder context)
|
||||
public string GetText(IEnumerable<IArgument>? arguments)
|
||||
{
|
||||
var index = _inputIndex ?? context?.ToString().CountOccurrences("-i") -1 ?? 0;
|
||||
arguments ??= Enumerable.Empty<IArgument>();
|
||||
|
||||
var index = 0;
|
||||
if (_inputIndex is null)
|
||||
{
|
||||
index = arguments
|
||||
.TakeWhile(x => x != this)
|
||||
.OfType<IInputArgument>()
|
||||
.Count();
|
||||
|
||||
index = Math.Max(index - 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = _inputIndex.Value;
|
||||
}
|
||||
|
||||
return $"-map_metadata {index}";
|
||||
}
|
||||
|
||||
|
||||
public Task During(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
|
@ -40,5 +58,7 @@ public void Post()
|
|||
public void Pre()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public FFMpegArgumentOptions WithAudioFilters(Action<AudioFilterOptions> audioFi
|
|||
public FFMpegArgumentOptions ForcePixelFormat(PixelFormat pixelFormat) => WithArgument(new ForcePixelFormat(pixelFormat));
|
||||
|
||||
public FFMpegArgumentOptions WithAudibleEncryptionKeys(string key, string iv) => WithArgument(new AudibleEncryptionKeyArgument(key, iv));
|
||||
public FFMpegArgumentOptions WithAudibleActivationBytes(string activationBytes) => WithArgument(new AudibleEncryptionKeyArgument(activationBytes));
|
||||
public FFMpegArgumentOptions WithTagVersion(int id3v2Version = 3) => WithArgument(new ID3V2VersionArgument(id3v2Version));
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue