void RenderPlay(Project project, TimelineEvent play) { Playlist playlist; EncodingSettings settings; EditionJob job; string outputDir, outputProjectDir, outputFile; if (Config.AutoRenderDir == null || !Directory.Exists (Config.AutoRenderDir)) { outputDir = Config.VideosDir; } else { outputDir = Config.AutoRenderDir; } outputProjectDir = Path.Combine (outputDir, Utils.SanitizePath (project.Description.DateTitle)); outputFile = String.Format ("{0}-{1}.mp4", play.EventType.Name, play.Name); outputFile = Utils.SanitizePath (outputFile, ' '); outputFile = Path.Combine (outputProjectDir, outputFile); try { PlaylistPlayElement element; Directory.CreateDirectory (outputProjectDir); settings = EncodingSettings.DefaultRenderingSettings (outputFile); playlist = new Playlist (); element = new PlaylistPlayElement (play, project.Description.FileSet); playlist.Elements.Add (element); job = new EditionJob (playlist, settings); renderer.AddJob (job); } catch (Exception ex) { Log.Exception (ex); } }
private void LoadEditionJob(EditionJob job) { videoEditor = multimediaToolkit.GetVideoEditor (); videoEditor.EncodingSettings = job.EncodingSettings; videoEditor.Progress += OnProgress; videoEditor.Error += OnError; foreach (IPlaylistElement segment in job.Playlist.Elements) { if (segment is PlaylistPlayElement) { ProcessPlay (segment as PlaylistPlayElement); } else if (segment is PlaylistVideo) { ProcessVideo (segment as PlaylistVideo); } else if (segment is PlaylistImage) { ProcessImage (segment as PlaylistImage); } else if (segment is PlaylistDrawing) { ProcessDrawing (segment as PlaylistDrawing); } } try { videoEditor.Start (); } catch (Exception ex) { videoEditor.Cancel (); job.State = JobState.Error; Log.Exception (ex); Log.Error ("Error rendering job: ", job.Name); guiToolkit.ErrorMessage (Catalog.GetString ("Error rendering job: ") + ex.Message); } }
public void TestRenderedCamera() { Project p = Utils.CreateProject (); try { TimelineEvent evt = p.Timeline [0]; evt.CamerasConfig = new List<CameraConfig> { new CameraConfig (0) }; PlaylistPlayElement element = new PlaylistPlayElement (evt, p.Description.FileSet); // Playlist with one event var playlist = new Playlist (); playlist.Elements.Add (element); // Create a job const string outputFile = "path"; EncodingSettings settings = new EncodingSettings (VideoStandards.P720, EncodingProfiles.MP4, EncodingQualities.Medium, 25, 1, outputFile, true, true, 20); EditionJob job = new EditionJob (playlist, settings); // Mock IMultimediaToolkit and video editor var mtk = Mock.Of<IMultimediaToolkit> (m => m.GetVideoEditor () == Mock.Of<IVideoEditor> ()); // and guitoolkit var gtk = Mock.Of<IGUIToolkit> (g => g.RenderingStateBar == Mock.Of<IRenderingStateBar> ()); // and a video editor Mock<IVideoEditor> mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ()); // And eventbroker Config.EventsBroker = Mock.Of<EventsBroker> (); // Create a rendering object with mocked interfaces RenderingJobsManager renderer = new RenderingJobsManager (mtk, gtk); // Start service renderer.Start (); renderer.AddJob (job); // Check that AddSegment is called with the right video file. mock.Verify (m => m.AddSegment (p.Description.FileSet [0].FilePath, evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true, new Area ()), Times.Once ()); /* Test with a camera index bigger than the total cameras */ renderer.CancelAllJobs (); mock.ResetCalls (); evt = p.Timeline [1]; evt.CamerasConfig = new List<CameraConfig> { new CameraConfig (1) }; element = new PlaylistPlayElement (evt, p.Description.FileSet); playlist.Elements [0] = element; job = new EditionJob (playlist, settings); renderer.AddJob (job); mock.Verify (m => m.AddSegment (p.Description.FileSet [1].FilePath, evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true, new Area ()), Times.Once ()); /* Test with the secondary camera */ renderer.CancelAllJobs (); mock.ResetCalls (); evt = p.Timeline [1]; evt.CamerasConfig = new List<CameraConfig> { new CameraConfig (2) }; element = new PlaylistPlayElement (evt, p.Description.FileSet); playlist.Elements [0] = element; job = new EditionJob (playlist, settings); renderer.AddJob (job); mock.Verify (m => m.AddSegment (p.Description.FileSet [0].FilePath, evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true, new Area ()), Times.Once ()); } finally { Utils.DeleteProject (p); } }