private void frmVideoInfo_Load(object sender, EventArgs e) { txtInfo.Text = _mp4Mod.GenerateStats(); txtInfo.SelectionStart = 0; btnSaveQuantMatrix.Visible = _mp4Mod.HasCustomIntraAndInterQuantMatrices; }
private static int Run() { if (!File.Exists(_pathSrc)) { throw new Exception("Source file doesn't exist."); } if ((_pathDst != null) && File.Exists(_pathDst)) { throw new Exception("Destination file already exists."); } bool modifying = false; _loading = true; AVIModifier aviMod = new AVIModifier(_pathSrc); MPEG4FrameModifier mp4Mod = new MPEG4FrameModifier(); aviMod.FrameModifier = mp4Mod; mp4Mod.VideoModifier = aviMod; aviMod.ProgressCallback = new ProgressCallback(Progress); aviMod.Preview(); Progress(1.0); Console.WriteLine(); if (_showInfo) { Console.WriteLine("---------- Video Info ----------"); Console.Write(mp4Mod.GenerateStats()); Console.WriteLine("--------------------------------"); } if (_writeFrameList) { Console.Write("Writing frame list..."); try { FileStream fs = new FileStream(_frameListPath, FileMode.CreateNew, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs)) { mp4Mod.DumpFrameList(sw); } } catch { Console.WriteLine(); throw new Exception("Cannot write frame list, make sure the file doesn't already exist."); } Console.WriteLine(" Done."); } if (_pathDst == null) { return(0); } if (_unpack && mp4Mod.IsPacked) { modifying = true; mp4Mod.NewIsPacked = false; mp4Mod.UserDataList = mp4Mod.SuggestedUserData(); } if (_pack && !mp4Mod.IsPacked && mp4Mod.ContainsBVOPs) { modifying = true; mp4Mod.NewIsPacked = true; mp4Mod.UserDataList = mp4Mod.SuggestedUserData(); } if (_changePAR || _changeDAR) { MPEG4PAR pold = mp4Mod.PARInfo; MPEG4PAR pnew = new MPEG4PAR(); if (_changePAR) { if (_parType != PARType.Custom) { pnew.Type = _parType; } else { pnew.SetCustomPAR(_customPAR); } } else if (_changeDAR) { double rar = (double)mp4Mod.FrameWidth / (double)mp4Mod.FrameHeight; pnew.SetCustomPAR(_customDAR / rar); } if ((pold.Type != pnew.Type) || ((pnew.Type == PARType.Custom) && ((pnew.Width != pold.Width) || (pnew.Height != pold.Height)))) { modifying = true; mp4Mod.PARInfo = pnew; } } if (_changeFieldOrder && mp4Mod.IsInterlaced && (mp4Mod.TopFieldFirst != _isTFF)) { modifying = true; mp4Mod.TopFieldFirst = _isTFF; } if (!modifying && !_alwaysWrite) { Console.WriteLine("Aborting: Video already has the desired format."); return(2); } _loading = false; aviMod.Write(_pathDst); Progress(1.0); Console.WriteLine(); Console.WriteLine("Video was written successfully."); return(0); }