private string GenerateCommandLine() { var sb = new StringBuilder(); var fps = _currentTask.VideoStream.Fps; int vidStream; var tempExt = Path.GetExtension(_currentTask.VideoStream.TempFile); if (_currentTask.VideoStream.IsRawStream) { vidStream = 0; } else if ((_currentTask.Input == InputType.InputAvi) && (!_currentTask.VideoStream.Encoded)) { vidStream = 0; } else if ((_currentTask.VideoStream.Encoded) || (tempExt == ".mp4")) { vidStream = 0; } else { vidStream = _currentTask.VideoStream.StreamId; } _outputFile = !string.IsNullOrEmpty(_currentTask.TempOutput) ? _currentTask.TempOutput : _currentTask.OutputFile; var fpsStr = string.Empty; if (_currentTask.VideoStream.IsRawStream) { fpsStr = _currentTask.VideoStream.FrameRateEnumerator == 0 || _appConfig.LastMp4BoxVer.StartsWith("0.5") ? $":fps={fps:0.000}".ToString(_appConfig.CInfo) : $":fps={_currentTask.VideoStream.FrameRateEnumerator:0}/{_currentTask.VideoStream.FrameRateDenominator:0}"; } sb.Append($"-add \"{_currentTask.VideoStream.TempFile}#video:trackID={vidStream:0}{fpsStr}:lang=eng\" -keep-sys "); _streamImportCount = 1; foreach (var item in _currentTask.AudioStreams) { var itemlang = item.LangCode; if ((itemlang == "xx") || (string.IsNullOrEmpty(itemlang))) { itemlang = "und"; } var delayString = string.Empty; if (item.Delay != 0) { delayString = $":delay={item.Delay:0}"; } sb.Append($"-add \"{item.TempFile}#audio:lang={itemlang}{delayString}\" -keep-sys "); _streamImportCount++; } foreach (var item in _currentTask.SubtitleStreams) { if (item.Format.ToLowerInvariant() != "utf-8") { continue; } if (!File.Exists(item.TempFile)) { continue; } var itemlang = item.LangCode; if ((itemlang == "xx") || (string.IsNullOrEmpty(itemlang))) { itemlang = "und"; } var delayString = string.Empty; if (item.Delay != 0) { delayString = $":delay={item.Delay:0}"; } sb.Append($"-add \"{item.TempFile}#lang={itemlang}{delayString}:name={LanguageHelper.GetLanguage(itemlang).FullLang}\" -keep-sys "); _streamImportCount++; } if (_currentTask.Chapters.Count > 1) { var chapterFile = FileSystemHelper.CreateTempFile( _appConfig.DemuxLocation, !string.IsNullOrEmpty(_currentTask.TempOutput) ? _currentTask.TempOutput : _currentTask.OutputFile, "chapters.ttxt"); var xmlSettings = new XmlWriterSettings { Indent = true, IndentChars = " ", Encoding = Encoding.UTF8, NewLineHandling = NewLineHandling.Entitize, ConformanceLevel = ConformanceLevel.Auto, CloseOutput = true }; var writer = XmlWriter.Create(chapterFile, xmlSettings); writer.WriteStartDocument(true); writer.WriteStartElement("TextStream"); writer.WriteAttributeString("version", "1.1"); int temp; var subHeight = Math.DivRem(_currentTask.VideoStream.Height, 3, out temp); subHeight += temp; writer.WriteStartElement("TextStreamHeader"); writer.WriteAttributeString("width", _currentTask.VideoStream.Width.ToString("G")); writer.WriteAttributeString("height", subHeight.ToString("G")); writer.WriteAttributeString("layer", "0"); writer.WriteAttributeString("translation_x", "0"); writer.WriteAttributeString("translation_y", "0"); writer.WriteStartElement("TextSampleDescription"); writer.WriteAttributeString("horizontalJustification", "center"); writer.WriteAttributeString("verticalJustification", "bottom"); writer.WriteAttributeString("backColor", "0 0 0 0"); writer.WriteAttributeString("verticalText", "no"); writer.WriteAttributeString("fillTextRegion", "no"); writer.WriteAttributeString("continousKaraoke", "no"); writer.WriteAttributeString("scroll", "None"); writer.WriteStartElement("FontTable"); writer.WriteStartElement("FontTableEntry"); writer.WriteAttributeString("fontName", "Arial"); writer.WriteAttributeString("fontID", "1"); writer.WriteEndElement(); // FontTableEntry writer.WriteEndElement(); // FontTable writer.WriteStartElement("TextBox"); writer.WriteAttributeString("top", "0"); writer.WriteAttributeString("left", "0"); writer.WriteAttributeString("bottom", _currentTask.VideoStream.Height.ToString("G")); writer.WriteAttributeString("right", _currentTask.VideoStream.Width.ToString("G")); writer.WriteEndElement(); // TextBox writer.WriteStartElement("Style"); writer.WriteAttributeString("styles", "Normal"); writer.WriteAttributeString("fontID", "1"); writer.WriteAttributeString("fontSize", "32"); writer.WriteAttributeString("color", "ff ff ff ff"); writer.WriteEndElement(); // Style writer.WriteEndElement(); // TextSampleDescription writer.WriteEndElement(); // TextStreamHeader for (var index = 0; index < _currentTask.Chapters.Count; index++) { var dt = DateTime.MinValue.Add(_currentTask.Chapters[index]); writer.WriteStartElement("TextSample"); writer.WriteAttributeString("sampleTime", dt.ToString("HH:mm:ss.fff")); writer.WriteValue($"Chapter {index + 1:0}"); writer.WriteEndElement(); // TextSample } writer.WriteEndElement(); // TextStream writer.WriteEndDocument(); writer.Flush(); writer.Close(); sb.Append($" -add \"{chapterFile}:chap\""); _currentTask.TempFiles.Add(chapterFile); _streamImportCount++; } var tool = $"{AppConfigService.GetProductName()} v{AppConfigService.GetAppVersion().ToString(4)}"; var tempPath = _appConfig.DemuxLocation; sb.Append($"-itags tool=\"{tool}\" -tmp \"{tempPath}\" -new \"{_outputFile}\""); return(sb.ToString()); }
private void CheckUpdateDoWork(object sender, DoWorkEventArgs e) { var needUpdate = false; var needCheck = false; switch (_configService.UpdateFrequency) { case 0: needCheck = true; break; case 1: if (_configService.LastUpdateRun.AddDays(1) < DateTime.Now) { needCheck = true; } break; case 2: if (_configService.LastUpdateRun.AddDays(7) < DateTime.Now) { needCheck = true; } break; } if (needCheck && System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { StatusLabel = "Checking for updates ..."; ShowStatusWindow = true; _processingService.GetUpdaterVersion(); _processingService.GetAviSynthPluginsVer(); var downloader = new WebClient { UseDefaultCredentials = true }; Stream onlineUpdateFile; try { onlineUpdateFile = downloader.OpenRead(new Uri("http://www.jt-soft.de/videoconvert/updatefile_7z.xml")); } catch (WebException exception) { Log.Error(exception); e.Result = false; return; } if (onlineUpdateFile == null) { e.Result = false; return; } using (var updateFile = Updater.LoadUpdateFileFromStream(onlineUpdateFile)) { if (updateFile.Core.PackageVersion.CompareTo(AppConfigService.GetAppVersion()) > 0) { needUpdate = true; } if (updateFile.Updater.PackageVersion.CompareTo(_configService.UpdaterVersion) > 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.AviSynthPlugins.PackageVersion, _configService.LastAviSynthPluginsVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.Profiles.PackageVersion, _configService.LastProfilesVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.X264.PackageVersion, _configService.Lastx264Ver) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.X26464.PackageVersion, _configService.Lastx26464Ver) != 0 && Environment.Is64BitOperatingSystem) { needUpdate = true; } if (string.CompareOrdinal(updateFile.FFMPEG.PackageVersion, _configService.LastffmpegVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.FFMPEG64.PackageVersion, _configService.Lastffmpeg64Ver) != 0 && Environment.Is64BitOperatingSystem) { needUpdate = true; } if (string.CompareOrdinal(updateFile.Eac3To.PackageVersion, _configService.Lasteac3ToVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.LsDvd.PackageVersion, _configService.LastlsdvdVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.MKVToolnix.PackageVersion, _configService.LastMKVMergeVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.Mplayer.PackageVersion, _configService.LastMplayerVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.TSMuxeR.PackageVersion, _configService.LastTSMuxerVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.MjpegTools.PackageVersion, _configService.LastMJPEGToolsVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.DVDAuthor.PackageVersion, _configService.LastDVDAuthorVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.MP4Box.PackageVersion, _configService.LastMp4BoxVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.HcEnc.PackageVersion, _configService.LastHcEncVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.OggEnc.PackageVersion, _configService.LastOggEncVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.OggEncLancer.PackageVersion, _configService.LastOggEncLancerVer) != 0 && _configService.UseOptimizedEncoders) { needUpdate = true; } if (string.CompareOrdinal(updateFile.Lame.PackageVersion, _configService.LastLameVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.VpxEnc.PackageVersion, _configService.LastVpxEncVer) != 0) { needUpdate = true; } if (string.CompareOrdinal(updateFile.BDSup2Sub.PackageVersion, _configService.LastBDSup2SubVer) != 0 && _configService.JavaInstalled) { needUpdate = true; } } Thread.Sleep(2000); StatusLabel = "Ready"; ShowStatusWindow = false; _configService.LastUpdateRun = DateTime.Now; } e.Result = needUpdate; }
internal void ReconfigureLogger() { var logFile = Path.Combine(_configService.AppSettingsPath, "ErrorLog_"); if (Log.Logger.Repository.Configured) { Log.Logger.Repository.Shutdown(); Log.Logger.Repository.ResetConfiguration(); } if (_clearLog) { try { File.Delete(logFile); } catch (Exception ex) { Debug.WriteLine(ex); } _clearLog = false; } var layout = new XmlLayoutSchemaLog4j(true); var filter = new LevelRangeFilter { LevelMin = _configService.UseDebug ? Level.All : Level.Warn, AcceptOnMatch = true }; layout.ActivateOptions(); var fileAppender = new RollingFileAppender { PreserveLogFileNameExtension = true, StaticLogFileName = false, DatePattern = "yyyyMMdd'.xml'", RollingStyle = RollingFileAppender.RollingMode.Date, ImmediateFlush = true, File = logFile, Encoding = new UTF8Encoding(true), Layout = layout, MaxSizeRollBackups = 60 }; fileAppender.AddFilter(filter); fileAppender.ActivateOptions(); BasicConfigurator.Configure(fileAppender); Log.Info($"Use Language: {_configService.UseLanguage}"); Log.Info($"VideoConvert v{AppConfigService.GetAppVersion().ToString(4)} started"); Log.Info($"OS-Version: {Environment.OSVersion.VersionString}"); Log.Info($"CPU-Count: {Environment.ProcessorCount:0}"); Log.Info($".NET Version: {Environment.Version.ToString(4)}"); Log.Info($"System Uptime: {TimeSpan.FromMilliseconds(Environment.TickCount).ToString("c")}"); var elevated = false; try { elevated = _processingService.IsProcessElevated(); } catch (Exception) { Log.Error("Could not determine process elevation status"); } if (Environment.OSVersion.Version.Major >= 6) { Log.Info($"Process Elevated: {elevated}"); } Extensions supExt; CpuExtensions.GetExtensions(out supExt); InspectCpuExtensions(supExt); if (_configService.UseDebug) { Log.Info("Debug information enabled"); } }