static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("file.mp4 [-e] [-s]"); return; } var filename = args[0]; using (var mp4file = MP4File.Parse(filename)) { if (args.Contains("-s")) { Display(mp4file.Nested, ""); } if (args.Contains("-e")) { foreach (var trak in mp4file.MOOV.TRAKS) { var trackname = filename + $".track.{trak.TrackId}.bin"; using (var filewrite = File.OpenWrite(trackname)) { trak.WriteAllTo(filewrite); } } } } }
public void TestSmallm4v() { using (var mp4file = MP4File.Parse("small.m4v")) { Assert.Equal <uint>(123551, mp4file.MOOV.TRAKS[0].TotalSize); var memoryStream = new MemoryStream(); mp4file.MOOV.TRAKS[0].WriteAllTo(memoryStream); var expected = File.ReadAllBytes("small.m4v.stream1"); var actual = memoryStream.ToArray(); Assert.Equal(expected, actual); } }
public void ParseHeaders(string filename, string majorBrand, UInt32 minorVersion, int trakCount, int compatibleBrandsCount) { output.WriteLine($"filename: {filename}"); using (var mp4file = MP4File.Parse(filename)) { Assert.Equal(majorBrand, mp4file.FTYP.MajorBrand); Assert.Equal(minorVersion, mp4file.FTYP.MinorVersion); Assert.Equal(compatibleBrandsCount, mp4file.FTYP.CompatibleBrands.Count); Assert.Equal(trakCount, mp4file.MOOV.TRAKS.Count); output.WriteLine($"majorbrand: {mp4file.FTYP.MajorBrand}"); output.WriteLine($"minorVersion: {mp4file.FTYP.MinorVersion}"); output.WriteLine($"tracks: {mp4file.MOOV.TRAKS.Count}"); foreach (var trak in mp4file.MOOV.TRAKS) { output.WriteLine($"trak: {trak.TrackId}, {trak.StreamName}, samples: {trak.SampleCount}, hdlr: {trak.MDIA.HDLR.ComponentType}, {trak.MDIA.HDLR.ComponentSubtype},{trak.MDIA.HDLR.ComponentName} "); } } }