diff --git a/src/Febe.Core/Codecs/Containers/ContainerReader.cs b/src/Febe.Core/Codecs/Containers/ContainerReader.cs
index 6aa585d..d9607f7 100644
--- a/src/Febe.Core/Codecs/Containers/ContainerReader.cs
+++ b/src/Febe.Core/Codecs/Containers/ContainerReader.cs
@@ -6,6 +6,12 @@ namespace Febe.Core.Codecs.Containers;
///
public static class ContainerReader
{
+ ///
+ /// A «now» far in the future, for readers that must not depend on the clock (frames, remux): every plausible date
+ /// in the file is accepted.
+ ///
+ internal static readonly DateTimeOffset AnyDate = new(9000, 1, 1, 0, 0, 0, TimeSpan.Zero);
+
/// The largest sample read into memory: an 8K frame of H.264 at its highest level stays far below.
public const int MaxSampleSize = 64 * 1024 * 1024;
diff --git a/src/Febe.Core/Codecs/Containers/IsoBmffReader.cs b/src/Febe.Core/Codecs/Containers/IsoBmffReader.cs
index 822574a..ae2923b 100644
--- a/src/Febe.Core/Codecs/Containers/IsoBmffReader.cs
+++ b/src/Febe.Core/Codecs/Containers/IsoBmffReader.cs
@@ -39,6 +39,7 @@ public static class IsoBmffReader
long position = 0;
Span header = stackalloc byte[16];
Movie? movie = null;
+ string? brand = null;
var pending = new List<(long Start, byte[] Body)>();
for (var i = 0; i < MaxTopLevelBoxes && position + 8 <= length; i++)
{
@@ -75,6 +76,12 @@ public static class IsoBmffReader
}
var type = header.Slice(4, 4);
+ if (type.SequenceEqual("ftyp"u8) && brand is null && size - headerSize >= 4)
+ {
+ stream.ReadExactly(header[..4]); // the size field is read already: its bytes can hold the brand
+ brand = System.Text.Encoding.Latin1.GetString(header[..4]);
+ }
+
if (type.SequenceEqual("moov"u8) && movie is null)
{
movie = ParseMoov(ReadBody(stream, position + headerSize, size - headerSize), now, samples, length);
@@ -112,7 +119,7 @@ public static class IsoBmffReader
throw new ContainerException("Manca il box moov.");
}
- return movie.Build();
+ return movie.Build(brand);
}
private static byte[] ReadBody(Stream stream, long offset, long count)
@@ -141,7 +148,11 @@ public static class IsoBmffReader
case "mvhd":
movie.ParseMvhd(body, now);
break;
+ case "udta" or "meta":
+ movie.HasUserData = true;
+ break;
case "trak":
+ movie.TrackCount++;
try
{
movie.ParseTrak(moov, start, count);
@@ -269,6 +280,11 @@ public static class IsoBmffReader
internal byte[]? Hvcc;
internal byte[]? Asc;
internal long EditOffset;
+ internal bool HasEdits;
+ internal long EmptyEditMovie;
+ internal int EditCount;
+ internal string? Language;
+ internal int ObjectType;
internal List Samples = [];
internal long FragmentTime = -1;
}
@@ -279,6 +295,7 @@ public static class IsoBmffReader
internal readonly Dictionary TrackDefaults = [];
private readonly List