/// <summary> /// demonstrates how to read AVIMAINHEADER of AVI format /// </summary> public static void ReadAviMainHeader() { //ExStart:ReadAviMainHeader // initialize AviFormat using (AviFormat aviFormat = new AviFormat(Common.MapSourceFilePath(filePath))) { // get AVI header AviHeader header = aviFormat.Header; // display video width Console.WriteLine("Video width: {0}", header.Width); // display video height Console.WriteLine("Video height: {0}", header.Height); // display total frames Console.WriteLine("Total frames: {0}", header.TotalFrames); // display number of streams in file Console.WriteLine("Number of streams: {0}", header.Streams); // display suggested buffer size for reading the file Console.WriteLine("Suggested buffer size: {0}", header.SuggestedBufferSize); } //ExEnd:ReadAviMainHeader }
/// <summary> /// Clean AVI Format Metadata /// Feature is supported in version 18.6 or greater of the API /// </summary> public static void ReadAviMainHeaderUsingStream() { using (Stream stream = File.Open(Common.MapDestinationFilePath(filePath), FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (AviFormat format = new AviFormat(Common.MapSourceFilePath(filePath))) { // get AVI header AviHeader header = format.Header; // display video width Console.WriteLine("Video width: {0}", header.Width); // display video height Console.WriteLine("Video height: {0}", header.Height); // display total frames Console.WriteLine("Total frames: {0}", header.TotalFrames); // display number of streams in file Console.WriteLine("Number of streams: {0}", header.Streams); // display suggested buffer size for reading the file Console.WriteLine("Suggested buffer size: {0}", header.SuggestedBufferSize); } // The stream is still open here } }
/// <summary> /// Shows how to read, update and remove XMP metadata in AVI format /// Feature is supported in version 17.06 or greater /// </summary> public static void DealWithXmpMetaData() { //ExStart:DealWithXmpMetaData // initialize AviFormat using (AviFormat aviFormat = new AviFormat(Common.MapSourceFilePath(filePath))) { // get XMP var xmpMetadata = aviFormat.GetXmpData(); // create XMP if absent if (xmpMetadata == null) { xmpMetadata = new XmpPacketWrapper(); } // setup properties xmpMetadata.Schemes.DublinCore.Format = "avi"; xmpMetadata.Schemes.XmpBasic.CreateDate = DateTime.UtcNow; xmpMetadata.Schemes.XmpBasic.CreatorTool = "GroupDocs.Metadata"; // update xmp aviFormat.SetXmpData(xmpMetadata); // and commit changes aviFormat.Save(); } //ExEnd:DealWithXmpMetaData }
public void Test_Avi_1() { var fn = @"Targets\Singles\CrimeBlimp.avi"; var file = new FileInfo(fn); using (var fs = new FileStream(fn, FileMode.Open, FileAccess.ReadWrite)) { var hdr = new byte[0x2C]; var got = fs.Read(hdr, 0, hdr.Length); Assert.AreEqual(hdr.Length, got); AviFormat.Model aviModel = AviFormat.CreateModel(fs, hdr, fs.Name); AviFormat avi = aviModel.Data; Assert.IsNotNull(avi); long fileSize = avi.FileSize; Assert.AreEqual(Severity.Warning, avi.Issues.MaxSeverity); Assert.AreEqual(1, avi.Issues.Items.Count); Assert.AreEqual(1, avi.Issues.RepairableCount); Assert.IsTrue(avi.Issues.Items[0].IsRepairable); Assert.AreEqual(5, avi.ExcessSize); Assert.AreEqual(Likeliness.Probable, avi.Watermark); string errMess = aviModel.IssueModel.Repair(0); Assert.IsNull(errMess); Assert.AreEqual(fileSize - 5, avi.FileSize); } }
public static void CleanMetadata() { //ExStart:CleanMetadata // initialize AviFormat AviFormat aviFormat = new AviFormat(Common.MapSourceFilePath(filePath)); // removes all metadata aviFormat.CleanMetadata(); // commit changes aviFormat.Save(); //ExEnd:DealWithXmpMetaData }
/// <summary> /// Detects AVI video format via Format Factory /// </summary> public static void DetectAviFormat() { //ExStart:DetectAviFormat // recognize format FormatBase format = FormatFactory.RecognizeFormat(Common.MapSourceFilePath(filePath)); // check format type if (format.Type == DocumentType.AVI) { // cast it to AviFormat AviFormat aviFormat = format as AviFormat; // and get it MIME type string mimeType = aviFormat.MIMEType; Console.WriteLine(mimeType); } //ExEnd:DetectAviFormat }