public override void Run(string part) { var fileText = FileReader.ReadFile(2018, 2); var reader = new BoxReader(fileText); Console.WriteLine(reader.CalculateCheckSum()); Console.WriteLine(reader.FindMostSimilarBoxIds()); }
public ISMVFile(string inDir, string inFileName) { strDir = inDir; strFileName = inFileName; boxReader = new BoxReader(File.Open(Path.Combine(inDir, inFileName), FileMode.Open, FileAccess.Read, FileShare.Read)); boxReader2 = new BoxReader(File.Open(Path.Combine(inDir, inFileName), FileMode.Open, FileAccess.Read, FileShare.Read)); ftb.Read(boxReader); mmb.Read(boxReader); BoxType nextType = boxReader.PeekNextBoxType(); }
/// <summary> /// Constructor to use when reading. /// </summary> /// <param name="inDir">Folder path</param> /// <param name="inFileName">ISMV file name</param> public ISMVTrackFormat(string inDir, string inFileName) { strDir = inDir; strFileName = inFileName; boxReader = new BoxReader(File.Open(Path.Combine(inDir, inFileName), FileMode.Open, FileAccess.Read, FileShare.Read)); ftb.Read(boxReader); mmb.Read(boxReader); //BoxType nextType = boxReader.PeekNextBoxType(); //ReadMP4Headers(); // just read the rest? _frameSize = new Size(); }
public ItemReferenceBox(BoxLocation location, SequentialReader reader) : base(location, reader) { var list = new List <SingleItemTypeReferenceBox>(); while (reader.IsWithinBox(location)) { var box = BoxReader.ReadBox(reader, (l, r) => new SingleItemTypeReferenceBox(l, r, Version)); if (box != null) { list.Add((SingleItemTypeReferenceBox)box); } } Boxes = list; }
public DataInformationBox(BoxLocation loc, SequentialReader sr) : base(loc) { Boxes = BoxReader.ReadBoxes(sr, loc); }
public ItemPropertyBox(BoxLocation loc, SequentialReader sr) : base(loc) { Boxes = BoxReader.ReadBoxes(sr, loc); }
private const int ExifTag = 0x45786966; // Exif public static DirectoryList ReadMetadata(Stream stream) { var directories = new List <Directory>(); // // Read all boxes from the file // var reader = new SequentialStreamReader(stream); var boxes = BoxReader.ReadBoxes(reader); // // Map those boxes to directories // ParseQuickTimeTest(); uint primaryItem = boxes.Descendant <PrimaryItemBox>()?.PrimaryItem ?? uint.MaxValue; var itemRefs = (boxes.Descendant <ItemReferenceBox>()?.Boxes ?? new SingleItemTypeReferenceBox[0]) .Where(i => i.Type == BoxTypes.ThmbTag || i.Type == BoxTypes.CdscTag).ToList(); ParseImageProperties(); if (stream.CanSeek) { ParseItemSegments(); } return(directories); void ParseQuickTimeTest() { if (boxes.Descendant <FileTypeBox>() is { } ftype) { var dir = new QuickTimeFileTypeDirectory(); if (ftype.MajorBrand > 0) { dir.Set(QuickTimeFileTypeDirectory.TagMajorBrand, ftype.MajorBrandString); } if (ftype.MinorBrand > 0) { dir.Set(QuickTimeFileTypeDirectory.TagMinorVersion, ftype.MinorBrandString); } if (ftype.CompatibleBrands.Count > 0) { dir.Set( QuickTimeFileTypeDirectory.TagCompatibleBrands, string.Join(", ", ftype.CompatibleBrandStrings.ToArray())); } directories.Add(dir); } } void ParseImageProperties() { uint[] allPrimaryTiles = (boxes.Descendant <ItemReferenceBox>()?.Boxes ?? new SingleItemTypeReferenceBox[0]) .SelectMany(i => i.FromItemId == primaryItem && i.Type == BoxTypes.DimgTag ? i.ToItemIds : new uint[0]) .ToArray(); var itemPropertyBox = boxes.Descendant <ItemPropertyBox>(); if (itemPropertyBox == null) { return; } var props = itemPropertyBox.Boxes.Descendant <ItemPropertyContainerBox>().Boxes; var associations = itemPropertyBox.Boxes.Descendant <ItemPropertyAssociationBox>(); ParsePropertyBoxes( "HEIC Primary Item Properties", ImageProperties(primaryItem, allPrimaryTiles, associations, props)); foreach (var itemRef in itemRefs) { ParsePropertyBoxes( "HEIC Thumbnail Properties", ImageProperties(itemRef.FromItemId, new uint[0], associations, props)); } return;
public DataReferenceBox(BoxLocation location, SequentialReader reader) : base(location, reader) { BoxCount = reader.GetUInt32(); Boxes = BoxReader.ReadBoxes(reader, location); }
public ItemInformationBox(BoxLocation location, SequentialReader reader) : base(location, reader) { Count = Version == 0 ? reader.GetUInt16() : reader.GetUInt32(); Boxes = BoxReader.ReadBoxes(reader, location); }
public MetaBox(BoxLocation location, SequentialReader reader) : base(location, reader) { Boxes = BoxReader.ReadBoxes(reader, location); }