public ActionResult AddVideo(VideoFileInfo videoInfo) { videoInfo.AddDate = DateTime.Now; videoInfo.DelFlag = 0; videoInfo.ImageUrl = "/Videos/Flv/" + Request["ImageUrl"] + ".jpg"; videoInfo.ModifyDate = DateTime.Now; videoInfo.VideoPath = "/Videos/Flv/" + Request["ImageUrl"] + ".flv"; int classId = int.Parse(Request["videoClass"]); return(Content(VideoFileInfoService.AddVideoFileInfo(classId, videoInfo) ? "ok" : "no")); }
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."); }
private static List <VideoFileInfo> GetAllVideoFileInfos(DirectoryInfo workingDirectory) { List <VideoFileInfo> mkvInfos = new List <VideoFileInfo>(); foreach (FileInfo mkvFile in workingDirectory.GetFiles("*.mkv", SearchOption.AllDirectories)) { FileInfo mkvInfoFile = new FileInfo(tempFolder.FullName + Path.DirectorySeparatorChar + mkvFile.Name + ".info"); String mkvInfoParameters = string.Format(mkvInfoBaseParameters, mkvFile.FullName, mkvInfoFile.FullName); //Console.WriteLine("mkvInfo Command:"); //Console.WriteLine(pathToMkvInfo + " " + mkvInfoParameters); Process mkvInfoProcess = StartExternalProcess(pathToMkvInfo, mkvInfoParameters); Console.WriteLine(mkvInfoProcess.StandardError.ReadToEnd()); mkvInfoProcess.WaitForExit(infoTimeOut * 1000); if (mkvInfoProcess.HasExited) { if (mkvInfoProcess.ExitCode != 0 || !mkvInfoFile.Exists) { Console.WriteLine("Error with mkvinfo tool when retrieving info for {0}", mkvFile.FullName); } else { try { VideoFileInfo mkvInfo = MKVInfoParser.MKVInfoProcessor.ParseMKVInfo(mkvInfoFile.FullName); mkvInfo.VideoFile = mkvFile; mkvInfos.Add(mkvInfo); } catch (Exception) { Console.WriteLine("Error parsing info for file {0}", mkvFile.FullName); } finally { mkvInfoFile.Delete(); } } } else { Console.WriteLine("MKV Info application took longer than {0} seconds when retrieving info for {1}", infoTimeOut, mkvFile.FullName); mkvInfoProcess.Kill(); } } return(mkvInfos); }
void LoadProject(Project project) { ProjectDescription pd = project.Description; loadedProject = null; gamedescriptionheader1.ProjectDescription = pd; seasonentry.Text = pd.Season; competitionentry.Text = pd.Competition; datepicker.Date = pd.MatchDate; templatelabel.Text = project.Dashboard.Name; desctextview.Buffer.Clear(); desctextview.Buffer.InsertAtCursor(project.Description.Description ?? ""); loadedProject = project; foreach (VideoFileInfo vfi in videoFileInfos) { videofileinfo_vbox.Remove(vfi); } videoFileInfos.Clear(); resyncbutton.Sensitive = project.Description.FileSet.Count > 1; int max = project.Description.FileSet.Count; // Cap to one media file for non multi camera version if (!Config.SupportsMultiCamera) { max = Math.Min(max, 1); } for (int i = 0; i < max; i++) { MediaFile mf = project.Description.FileSet [i]; VideoFileInfo vfi = new VideoFileInfo(); vfi.SetMediaFileSet(project.Description.FileSet, mf); vfi.Changed += HandleChanged; vfi.ShowAll(); videoFileInfos.Add(vfi); videofileinfo_vbox.PackStart(vfi, true, true, 0); } projectbox.Visible = true; edited = false; }
static void Main() { try { DocumentFileInfo document = new DocumentFileInfo("autistfil", 12, new DateTime(2004, 12, 02)); ImageFileInfo image = new ImageFileInfo(1920, 984, "autist", 23, new DateTime(1982, 09, 12)); VideoFileInfo video = new VideoFileInfo(1920, 1080, "film om autisme", 100, 34, new DateTime(1971, 09, 12)); Console.WriteLine(video); } catch (ArgumentOutOfRangeException e) { Console.WriteLine(e.Message); } }
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult) { var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path); Assert.NotNull(result); Assert.Equal(result.Path, expectedResult.Path); Assert.Equal(result.Container, expectedResult.Container); Assert.Equal(result.Name, expectedResult.Name); Assert.Equal(result.Year, expectedResult.Year); Assert.Equal(result.ExtraType, expectedResult.ExtraType); Assert.Equal(result.Format3D, expectedResult.Format3D); Assert.Equal(result.Is3D, expectedResult.Is3D); Assert.Equal(result.IsStub, expectedResult.IsStub); Assert.Equal(result.StubType, expectedResult.StubType); Assert.Equal(result.IsDirectory, expectedResult.IsDirectory); Assert.Equal(result.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension); }
public List <VideoFileInfo> FindVideoFiles() { DirectoryInfo info = new DirectoryInfo(this.videoFolderParh); List <VideoFileInfo> result = new List <VideoFileInfo>(); foreach (FileInfo file in info.GetFiles("*.mp4")) { VideoFileInfo videoFile = new VideoFileInfo() { DisplayName = file.Name, Id = file.Name }; result.Add(videoFile); } return(result); }
private static void ConvertFlacToAac(VideoFileInfo mkvFile) { foreach (TrackInfo track in mkvFile.Tracks) { if (track.Codec == flacCodecID) { Console.WriteLine("Transcoding FLAC streams {0}(id:{1}) from {2}", track.Name, track.TrackNumber, mkvFile.VideoFile.FullName); FileInfo aacFile = new FileInfo(tempFolder.FullName + Path.DirectorySeparatorChar + mkvFile.VideoFile.Name + '.' + track.MkvToolsTrackNumber + ".mp4"); String ffmpegParameters = String.Format(ffMpegBaseParameters, mkvFile.VideoFile.FullName, track.MkvToolsTrackNumber); String neroAacParameters = String.Format(neroAacEncBaseParameters, aacFile.FullName); String fullCommand = pathToFFMpeg + " " + ffmpegParameters + " | " + pathToNeroAacEnc + " " + neroAacParameters; //We pipe the stream from ffmpeg directly into the neroAAC encoder. Console.WriteLine("ffmpeg to neroAAC Command:"); Console.WriteLine(fullCommand); Process transcodeProcess = StartExternalProcess("cmd", "/C " + fullCommand); Console.WriteLine(transcodeProcess.StandardError.ReadToEnd()); transcodeProcess.WaitForExit(encodeTimeout * 1000); if (transcodeProcess.HasExited) { if (transcodeProcess.ExitCode != 0 || !aacFile.Exists) { Console.WriteLine("Error with transcoding"); } else { track.ExternalFileRef = aacFile; } } else { Console.WriteLine("MKV transcode application took longer than {0} seconds.", encodeTimeout); transcodeProcess.Kill(); } } } }
public VAFileInfo GetVAFileInfo(VideoFileInfo vFileInfo, CameraInfo camera) { string dtStart = vFileInfo.StartTime.ToString(DataModel.Constant.DATETIME_FORMAT); string dtEnd = vFileInfo.EndTime.ToString(DataModel.Constant.DATETIME_FORMAT); VAFileInfo vaFileInfo = new VAFileInfo() { CameraName = camera.CameraName, CameraId = camera.CameraID, FileSize = vFileInfo.Size, FileName = string.Format("{0}_{1} - {2}", camera.CameraName, dtStart, dtEnd), AdjustTime = vFileInfo.StartTime.ToString(DataModel.Constant.DATETIME_FORMAT), FileFullName = string.Format("{0} - {1}", vFileInfo.StartTime.ToString(DataModel.Constant.DATETIME_FORMAT), vFileInfo.EndTime.ToString(DataModel.Constant.DATETIME_FORMAT)), StartTime = vFileInfo.StartTime, EndTime = vFileInfo.EndTime }; return(vaFileInfo); }
private static void RemuxFile(VideoFileInfo mkvFile, DirectoryInfo targetFolder) { FileInfo target = new FileInfo(targetFolder.FullName + Path.DirectorySeparatorChar + mkvFile.VideoFile.Name); Console.WriteLine("Remuxing {0} to {1}", mkvFile.VideoFile.FullName, target.FullName); String mkvMergeParams = PrepareMkvMergeParameters(mkvFile, target); Console.WriteLine("MkvMerge Command:"); Console.WriteLine(pathToMkvMerge + " " + mkvMergeParams); Process mkvMergeProcess = StartExternalProcess(pathToMkvMerge, mkvMergeParams); Console.WriteLine(mkvMergeProcess.StandardError.ReadToEnd()); mkvMergeProcess.WaitForExit(mergeTimeout * 1000); if (mkvMergeProcess.HasExited) { target.Refresh(); if (mkvMergeProcess.ExitCode != 0 || !target.Exists) { Console.WriteLine("Error with mkvMerge"); } else { foreach (TrackInfo track in mkvFile.Tracks) { if (track.ExternalFileRef != null && track.ExternalFileRef.Exists) { track.ExternalFileRef.Delete(); } } } } else { Console.WriteLine("MKV merge application took longer than {0} seconds.", mergeTimeout); mkvMergeProcess.Kill(); } }
protected void SetVideoType(Video video, VideoFileInfo videoInfo) { var extension = Path.GetExtension(video.Path); video.VideoType = string.Equals(extension, ".iso", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".img", StringComparison.OrdinalIgnoreCase) ? VideoType.Iso : VideoType.VideoFile; video.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase); video.IsPlaceHolder = videoInfo.IsStub; if (videoInfo.IsStub) { if (string.Equals(videoInfo.StubType, "dvd", StringComparison.OrdinalIgnoreCase)) { video.VideoType = VideoType.Dvd; } else if (string.Equals(videoInfo.StubType, "hddvd", StringComparison.OrdinalIgnoreCase)) { video.VideoType = VideoType.HdDvd; video.IsHD = true; } else if (string.Equals(videoInfo.StubType, "bluray", StringComparison.OrdinalIgnoreCase)) { video.VideoType = VideoType.BluRay; video.IsHD = true; } else if (string.Equals(videoInfo.StubType, "hdtv", StringComparison.OrdinalIgnoreCase)) { video.IsHD = true; } } SetIsoType(video); }
/// <summary> /// Resolves the video. /// </summary> /// <typeparam name="TVideoType">The type of the T video type.</typeparam> /// <param name="args">The args.</param> /// <param name="parseName">if set to <c>true</c> [parse name].</param> /// <returns>``0.</returns> protected TVideoType ResolveVideo <TVideoType>(ItemResolveArgs args, bool parseName) where TVideoType : Video, new() { var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); // If the path is a file check for a matching extensions var parser = new Naming.Video.VideoResolver(namingOptions, new Naming.Logging.NullLogger()); if (args.IsDirectory) { TVideoType video = null; VideoFileInfo videoInfo = null; // Loop through each child file/folder and see if we find a video foreach (var child in args.FileSystemChildren) { var filename = child.Name; if ((child.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { if (IsDvdDirectory(filename)) { videoInfo = parser.ResolveDirectory(args.Path); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.Dvd, ProductionYear = videoInfo.Year }; break; } if (IsBluRayDirectory(filename)) { videoInfo = parser.ResolveDirectory(args.Path); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.BluRay, ProductionYear = videoInfo.Year }; break; } } else if (IsDvdFile(filename)) { videoInfo = parser.ResolveDirectory(args.Path); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.Dvd, ProductionYear = videoInfo.Year }; break; } } if (video != null) { video.Name = parseName ? videoInfo.Name : Path.GetFileName(args.Path); Set3DFormat(video, videoInfo); } return(video); } else { var videoInfo = parser.ResolveFile(args.Path); if (videoInfo == null) { return(null); } if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub) { var path = args.Path; var video = new TVideoType { Path = path, IsInMixedFolder = true, ProductionYear = videoInfo.Year }; SetVideoType(video, videoInfo); video.Name = parseName ? videoInfo.Name : Path.GetFileNameWithoutExtension(args.Path); Set3DFormat(video, videoInfo); return(video); } } return(null); }
protected void Set3DFormat(Video video, VideoFileInfo videoInfo) { Set3DFormat(video, videoInfo.Is3D, videoInfo.Format3D); }
private bool ContainsFile(VideoFileInfo result, FileSystemMetadata file) { return(string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase)); }
static void Main(string[] args) { VideoFileInfo vfi = MKVInfoProcessor.ParseMKVInfo("mkvinfo.txt"); return; }
private static void TranscodeFlac(VideoFileInfo mkvFile, DirectoryInfo targetFolder) { ConvertFlacToAac(mkvFile); RemuxFile(mkvFile, targetFolder); }
private static String PrepareMkvMergeParameters(VideoFileInfo mkvFile, FileInfo target) { StringBuilder mkvMergeParams = new StringBuilder(); mkvMergeParams.AppendFormat("-o \"{0}\"", target.FullName); if (!String.IsNullOrWhiteSpace(mkvFile.SegmentUID)) { mkvMergeParams.AppendFormat(" --segment-uid \"{0}\"", mkvFile.SegmentUID); //we keep the same segmentUID as source to preserve external chapter support. (OP/ED's etc) } List <String> audioIdsToSkip = new List <String>(); foreach (TrackInfo track in mkvFile.Tracks) { if (track.TrackType == TrackType.Video) { mkvMergeParams.AppendFormat(" --compression {0}:none", track.MkvToolsTrackNumber); } if (track.TrackType == TrackType.Audio && track.Codec == flacCodecID) { audioIdsToSkip.Add(track.MkvToolsTrackNumber.ToString()); } } mkvMergeParams.AppendFormat(" --audio-tracks !{0}", String.Join(",", audioIdsToSkip)); mkvMergeParams.AppendFormat(" \"{0}\"", mkvFile.VideoFile.FullName); foreach (TrackInfo track in mkvFile.Tracks) { if (track.TrackType == TrackType.Audio && track.Codec == flacCodecID) { String reworkedTrackName = ReplaceFlacIndicator(track.Name); if (!String.IsNullOrWhiteSpace(reworkedTrackName)) { mkvMergeParams.AppendFormat(" --track-name \"0:{0}\"", reworkedTrackName); } if (String.IsNullOrWhiteSpace(track.Language)) //eng is the default track language, this is sometimes ommited in the source files resulting in an empty language code. { mkvMergeParams.AppendFormat(" --language 0:eng"); } else { mkvMergeParams.AppendFormat(" --language 0:{0}", track.Language); }; mkvMergeParams.AppendFormat(" --compression 0:none"); if (!track.Default) //yes is the default value of this flag, there is no need to specify this case. { mkvMergeParams.Append(" --default-track 0:no"); } if (track.Forced) { mkvMergeParams.Append(" --forced-track 0:yes"); } //Ensure we only grab audio from this file mkvMergeParams.Append(" --no-video --no-subtitles --no-buttons --no-track-tags"); mkvMergeParams.Append(" --no-chapters --no-attachments --no-global-tags"); mkvMergeParams.AppendFormat(" --audio-tracks 0 \"{0}\"", track.ExternalFileRef.FullName); } } List <String> trackOrder = new List <String>(); Int32 externalFileCounter = 0; foreach (TrackInfo track in mkvFile.Tracks) { if (track.TrackType == TrackType.Audio && track.Codec == flacCodecID) { externalFileCounter += 1; trackOrder.Add(String.Format("{0}:0", externalFileCounter)); } else { trackOrder.Add(String.Format("0:{0}", track.MkvToolsTrackNumber)); } } mkvMergeParams.AppendFormat(" --track-order {0}", String.Join(",", trackOrder)); return(mkvMergeParams.ToString()); }
protected virtual TVideoType ResolveVideo <TVideoType>(ItemResolveArgs args, bool parseName) where TVideoType : Video, new() { var namingOptions = NamingOptions; // If the path is a file check for a matching extensions if (args.IsDirectory) { TVideoType video = null; VideoFileInfo videoInfo = null; // Loop through each child file/folder and see if we find a video foreach (var child in args.FileSystemChildren) { var filename = child.Name; if (child.IsDirectory) { if (IsDvdDirectory(child.FullName, filename, args.DirectoryService)) { videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.Dvd, ProductionYear = videoInfo.Year }; break; } if (IsBluRayDirectory(filename)) { videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.BluRay, ProductionYear = videoInfo.Year }; break; } } else if (IsDvdFile(filename)) { videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions); if (videoInfo == null) { return(null); } video = new TVideoType { Path = args.Path, VideoType = VideoType.Dvd, ProductionYear = videoInfo.Year }; break; } } if (video != null) { video.Name = parseName ? videoInfo.Name : Path.GetFileName(args.Path); Set3DFormat(video, videoInfo); } return(video); } else { var videoInfo = VideoResolver.Resolve(args.Path, false, namingOptions, false); if (videoInfo == null) { return(null); } if (VideoResolver.IsVideoFile(args.Path, NamingOptions) || videoInfo.IsStub) { var path = args.Path; var video = new TVideoType { Path = path, IsInMixedFolder = true, ProductionYear = videoInfo.Year }; SetVideoType(video, videoInfo); video.Name = parseName ? videoInfo.Name : Path.GetFileNameWithoutExtension(args.Path); Set3DFormat(video, videoInfo); return(video); } } return(null); }
private VideoStream(VideoFileInfo openedfileInfo, string fileName) { m_OpenedFileInfo = openedfileInfo; m_FileName = fileName; }
protected virtual TVideoType ResolveVideo <TVideoType>(ItemResolveArgs args, bool parseName) where TVideoType : Video, new() { VideoFileInfo videoInfo = null; VideoType? videoType = null; // If the path is a file check for a matching extensions if (args.IsDirectory) { // Loop through each child file/folder and see if we find a video foreach (var child in args.FileSystemChildren) { var filename = child.Name; if (child.IsDirectory) { if (IsDvdDirectory(child.FullName, filename, args.DirectoryService)) { videoType = VideoType.Dvd; } else if (IsBluRayDirectory(filename)) { videoType = VideoType.BluRay; } } else if (IsDvdFile(filename)) { videoType = VideoType.Dvd; } if (videoType == null) { continue; } videoInfo = VideoResolver.ResolveDirectory(args.Path, NamingOptions, parseName); break; } } else { videoInfo = VideoResolver.Resolve(args.Path, false, NamingOptions, parseName); } if (videoInfo == null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions))) { return(null); } var video = new TVideoType { Name = videoInfo.Name, Path = args.Path, ProductionYear = videoInfo.Year, ExtraType = videoInfo.ExtraType }; if (videoType.HasValue) { video.VideoType = videoType.Value; } else { SetVideoType(video, videoInfo); } Set3DFormat(video, videoInfo); return(video); }