mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Support external decoders that don't report valid length in wav header
This commit is contained in:
@@ -202,7 +202,7 @@ namespace CUETools.Codecs
|
||||
_dataOffset = pos;
|
||||
if (!_IO.CanSeek || _IO.Length <= maxFileSize)
|
||||
{
|
||||
if (ckSize >= 0x7fffffff)
|
||||
if (ckSize == 0 || ckSize >= 0x7fffffff)
|
||||
_dataLen = -1;
|
||||
else
|
||||
_dataLen = (long)ckSize;
|
||||
|
||||
@@ -161,6 +161,7 @@ namespace CUETools.Processor
|
||||
{
|
||||
encoders.Add(new CUEToolsUDC("flake", "flac", true, "0 1 2 3 4 5 6 7 8 9 10 11 12", "8", "flake.exe", "-%M - -o %O -p %P"));
|
||||
encoders.Add(new CUEToolsUDC("takc", "tak", true, "0 1 2 2e 2m 3 3e 3m 4 4e 4m", "2", "takc.exe", "-e -p%M -overwrite - %O"));
|
||||
encoders.Add(new CUEToolsUDC("WMAEncode", "wma", true, "", "", "WMAEncode.exe", "-i -c lossless - %O"));
|
||||
encoders.Add(new CUEToolsUDC("ffmpeg alac", "m4a", true, "", "", "ffmpeg.exe", "-i - -f ipod -acodec alac -y %O"));
|
||||
encoders.Add(new CUEToolsUDC("VBR (lame.exe)", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", "lame.exe", "--vbr-new -%M - %O"));
|
||||
encoders.Add(new CUEToolsUDC("CBR (lame.exe)", "mp3", false, "96 128 192 256 320", "256", "lame.exe", "-m s -q 0 -b %M --noreplaygain - %O"));
|
||||
@@ -169,7 +170,8 @@ namespace CUETools.Processor
|
||||
encoders.Add(new CUEToolsUDC("qaac tvbr", "m4a", false, "10 20 30 40 50 60 70 80 90 100 110 127", "80", "qaac.exe", "-s -V %M -q 2 - -o %O"));
|
||||
|
||||
decoders.Add("takc", new CUEToolsUDC("takc", "tak", true, "", "", "takc.exe", "-d %I -"));
|
||||
decoders.Add("ffmpeg alac", new CUEToolsUDC("ffmpeg alac", "m4a", true, "", "", "ffmpeg.exe", "%I -f wav -"));
|
||||
decoders.Add("ffmpeg alac", new CUEToolsUDC("ffmpeg alac", "m4a", true, "", "", "ffmpeg.exe", "-v 0 -i %I -f wav -"));
|
||||
decoders.Add("wma2wav", new CUEToolsUDC("wma2wav", "wma", true, "", "", "ffmpeg.exe", "-v 0 -i %I -f wav -"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,6 +186,7 @@ namespace CUETools.Processor
|
||||
formats.Add("wav", new CUEToolsFormat("wav", CUEToolsTagger.TagLibSharp, true, false, true, false, true, encoders.GetDefault("wav", true), null, GetDefaultDecoder("wav")));
|
||||
formats.Add("m4a", new CUEToolsFormat("m4a", CUEToolsTagger.TagLibSharp, true, true, false, false, true, encoders.GetDefault("m4a", true), encoders.GetDefault("m4a", false), GetDefaultDecoder("m4a")));
|
||||
formats.Add("tak", new CUEToolsFormat("tak", CUEToolsTagger.APEv2, true, false, true, true, true, encoders.GetDefault("tak", true), null, "takc"));
|
||||
formats.Add("wma", new CUEToolsFormat("wma", CUEToolsTagger.TagLibSharp, true, true, false, false, true, encoders.GetDefault("wma", true), null, "wma2wav"));
|
||||
formats.Add("mp3", new CUEToolsFormat("mp3", CUEToolsTagger.TagLibSharp, false, true, false, false, true, null, encoders.GetDefault("mp3", false), null));
|
||||
formats.Add("ogg", new CUEToolsFormat("ogg", CUEToolsTagger.TagLibSharp, false, true, false, false, true, null, encoders.GetDefault("ogg", false), null));
|
||||
|
||||
|
||||
@@ -2180,15 +2180,24 @@ namespace CUETools.Processor
|
||||
? (TagLib.File.IFileAbstraction)new ArchiveFileAbstraction(this, path)
|
||||
: (TagLib.File.IFileAbstraction)new TagLib.File.LocalFileAbstraction(path);
|
||||
fileInfo = TagLib.File.Create(file);
|
||||
if (fileInfo.Properties.AudioSampleCount > 0)
|
||||
return (int)fileInfo.Properties.AudioSampleCount;
|
||||
}
|
||||
|
||||
IAudioSource audioSource = AudioReadWrite.GetAudioSource(path, _isArchive ? OpenArchive(path, true) : null, _config);
|
||||
try
|
||||
{
|
||||
if (!audioSource.PCM.IsRedBook ||
|
||||
audioSource.Length <= 0 ||
|
||||
if (!audioSource.PCM.IsRedBook)
|
||||
throw new Exception("Audio format is not Red Book PCM.");
|
||||
if (audioSource.Length <= 0)
|
||||
{
|
||||
AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);
|
||||
while (audioSource.Read(buff, -1) != 0)
|
||||
CheckStop();
|
||||
}
|
||||
if (audioSource.Length <= 0 ||
|
||||
audioSource.Length >= Int32.MaxValue)
|
||||
throw new Exception("Audio format is invalid.");
|
||||
throw new Exception("Audio file length is unknown or invalid.");
|
||||
return (int)audioSource.Length;
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -212,6 +212,22 @@ namespace TagLib.Aac
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -278,6 +278,22 @@ namespace TagLib.Aiff
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -305,6 +305,22 @@ namespace TagLib.Ape {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -133,6 +133,22 @@ namespace TagLib.Flac
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -125,6 +125,16 @@ namespace TagLib {
|
||||
/// </value>
|
||||
int AudioBitrate {get;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
long AudioSampleCount {get;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -135,6 +135,21 @@ namespace TagLib.Matroska
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Audio track sampling rate.
|
||||
/// </summary>
|
||||
|
||||
@@ -216,6 +216,22 @@ namespace TagLib.MusePack {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -361,6 +361,22 @@ namespace TagLib.Mpeg {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -195,6 +195,22 @@ namespace TagLib.Mpeg4 {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -215,6 +215,22 @@ namespace TagLib.Ogg.Codecs
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -246,6 +246,34 @@ namespace TagLib {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (ICodec codec in codecs)
|
||||
{
|
||||
if (codec == null ||
|
||||
(codec.MediaTypes & MediaTypes.Audio) == 0)
|
||||
continue;
|
||||
|
||||
IAudioCodec audio = codec as IAudioCodec;
|
||||
|
||||
if (audio != null && audio.AudioSampleCount != 0)
|
||||
return audio.AudioSampleCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -205,6 +205,22 @@ namespace TagLib.Riff {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio represented by the
|
||||
/// current instance.
|
||||
|
||||
@@ -150,6 +150,22 @@ namespace TagLib.WavPack {
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample count of the audio represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="int" /> value containing the sample count
|
||||
/// of the audio represented by the current instance.
|
||||
/// </value>
|
||||
public long AudioSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the media represented by the current
|
||||
/// instance.
|
||||
|
||||
Reference in New Issue
Block a user