internal static VideoStream OpenFileForAutomation(string fileName, int videoEngineId) { List <string> allEngines = TangraVideo.EnumVideoEngines().ToList(); var allEnginesByAttemptOrder = new List <string>(allEngines); allEnginesByAttemptOrder.RemoveAt(videoEngineId); allEnginesByAttemptOrder.Insert(0, allEngines[videoEngineId]); Dictionary <int, string> allEnginesByIndex = allEnginesByAttemptOrder.ToDictionary(x => allEngines.IndexOf(x), x => x); foreach (int engineIdx in allEnginesByIndex.Keys) { try { TangraVideo.SetVideoEngine(engineIdx); VideoFileInfo fileInfo = TangraVideo.OpenFile(fileName); var rv = new VideoStream(fileInfo, fileName); // Try to load the first frame to be sure that it is going to work, before accepting this video engine for rendering rv.GetPixelmap(fileInfo.FirstFrame); return(rv); } catch (Exception ex) { Trace.WriteLine(ex.GetFullStackTrace()); } } return(null); }
public static VideoStream OpenFile(string fileName) { List <string> allEngines = TangraVideo.EnumVideoEngines().ToList(); var allEnginesByAttemptOrder = new List <string>(allEngines); allEnginesByAttemptOrder.RemoveAt(TangraConfig.Settings.Generic.AviRenderingEngineIndex); allEnginesByAttemptOrder.Insert(0, allEngines[TangraConfig.Settings.Generic.AviRenderingEngineIndex]); Dictionary <int, string> allEnginesByIndex = allEnginesByAttemptOrder.ToDictionary(x => allEngines.IndexOf(x), x => x); Exception lastError = null; foreach (int engineIdx in allEnginesByIndex.Keys) { try { TangraVideo.SetVideoEngine(engineIdx); VideoFileInfo fileInfo = TangraVideo.OpenFile(fileName); if (fileInfo.Height < 0) { MessageBox.Show("This appears to be a top-down DIB bitmap which is not supported by Tangra. If this video was recorded with ASICAP then please either use a different recording software or a different file format such as SER, FITS or ADV.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new NotSupportedException("Top-down DIB bitmaps are not supported by Tangra."); } TangraContext.Current.RenderingEngine = allEnginesByIndex[engineIdx]; var rv = new VideoStream(fileInfo, fileName); // Try to load the first frame to be sure that it is going to work, before accepting this video engine for rendering rv.GetPixelmap(fileInfo.FirstFrame); UsageStats.Instance.ProcessedAviFiles++; if (allEnginesByIndex[engineIdx] == "VideoForWindows") { UsageStats.Instance.VideoForWindowsUsed++; } else if (allEnginesByIndex[engineIdx] == "DirectShow") { UsageStats.Instance.DirectShowUsed++; } UsageStats.Instance.Save(); return(rv); } catch (Exception ex) { lastError = ex; } } throw new InvalidVideoFileException(lastError != null ? lastError.Message : "None of the rendering engines was able to open the file."); }
public static VideoStream OpenFile(string fileName) { List <string> allEngines = TangraVideo.EnumVideoEngines().ToList(); var allEnginesByAttemptOrder = new List <string>(allEngines); allEnginesByAttemptOrder.RemoveAt(TangraConfig.Settings.Generic.AviRenderingEngineIndex); allEnginesByAttemptOrder.Insert(0, allEngines[TangraConfig.Settings.Generic.AviRenderingEngineIndex]); Dictionary <int, string> allEnginesByIndex = allEnginesByAttemptOrder.ToDictionary(x => allEngines.IndexOf(x), x => x); Exception lastError = null; foreach (int engineIdx in allEnginesByIndex.Keys) { try { TangraVideo.SetVideoEngine(engineIdx); VideoFileInfo fileInfo = TangraVideo.OpenFile(fileName); TangraContext.Current.RenderingEngine = allEnginesByIndex[engineIdx]; var rv = new VideoStream(fileInfo, fileName); // Try to load the first frame to be sure that it is going to work, before accepting this video engine for rendering rv.GetPixelmap(fileInfo.FirstFrame); UsageStats.Instance.ProcessedAviFiles++; if (allEnginesByIndex[engineIdx] == "VideoForWindows") { UsageStats.Instance.VideoForWindowsUsed++; } else if (allEnginesByIndex[engineIdx] == "DirectShow") { UsageStats.Instance.DirectShowUsed++; } UsageStats.Instance.Save(); return(rv); } catch (Exception ex) { lastError = ex; } } throw new InvalidVideoFileException(lastError != null ? lastError.Message : "None of the rendering engines was able to open the file."); }