/// <summary> /// To use: Prepare Windows Media Writer and other objects, construct, call the Encode method, /// use properties and other methods to get results, release, close Windows Media Writer. /// </summary> /// <param name="segment">Batch params for this segment. We assume all fields have already been validated.</param> /// <param name="jobStart">Absolute start time of the first segment of the job in ticks</param> /// <param name="offset">The total timespan in ticks of all previous segments in this job</param> /// <param name="wmWriter">Windows Media Writer object to write to. We assume it has been preconfigured and started.</param> /// <param name="progressTracker">Where to put UI status updates</param> /// <param name="logMgr">Where to put log messages</param> /// <param name="profileData">compressed media types we are writing to in the norecompression case</param> public WMSegment(ArchiveTranscoderJob job, ArchiveTranscoderJobSegment segment, long jobStart, long offset, WMWriter wmWriter, ProgressTracker progressTracker, LogMgr logMgr, ProfileData profileData, bool norecompression, WMSegment previousSegment) { cancel = false; this.logMgr = logMgr; this.job = job; this.segment = segment; this.offset = offset; this.jobStart = jobStart; this.progressTracker = progressTracker; this.profileData = profileData; this.norecompression = norecompression; this.m_PreviousSegment = previousSegment; videoStream = null; slideStream = null; audioStreams = null; presentationMgr = null; writer = wmWriter; startTime = endTime = DateTime.MinValue; startTime = DateTime.Parse(segment.StartTime); endTime = DateTime.Parse(segment.EndTime); useSlideStream = false; if (Utility.SegmentFlagIsSet(segment, SegmentFlags.SlidesReplaceVideo)) { useSlideStream = true; } }
private SlideImageGenerator(ArchiveTranscoderJob job, ProgressTracker progressTracker, LogMgr log) { stopNow = false; this.job = job; this.log = log; this.progressTracker = progressTracker; this.rtDocuments = null; this.slideMessages = null; outputDirs = new Hashtable(); //This is to work around an issue with CP3 which can cause elements on slides to be shifted a little bit to the right, //causing archived ink to be misaligned. To work around, we shift the slide images to approximate what CP3 did. rightShift = 0; if (ConfigurationManager.AppSettings["RightShiftPPTImage"] != null) { int s; if (int.TryParse(ConfigurationManager.AppSettings["RightShiftPPTImage"], out s)) { if (s > 0) { Console.WriteLine("Right shifting images by: " + s.ToString()); rightShift = s; } } } // By default we use CP3 to export PPT slide images because we get the image alignment that matches // ink, and get the same appearance that was seen in the classroom. However the following two options // allow us to revert to exporting images from the PowerPoint application instead. //While we can get better quality from PPT images using export to wmf, some unusual characters will not //appear correctly (eg. the lambda character converts as a '?'). However if we export from PPT to JPEG, //somewhat more of the characters are correct. /// Set this option to make PPT export directly to JPG useNativeJpegExport = false; if (ConfigurationManager.AppSettings["PPT2JpegExport"] != null) { bool b; if (bool.TryParse(ConfigurationManager.AppSettings["PPT2JpegExport"], out b)) { Console.WriteLine("Using native PPT to Jpeg export."); useNativeJpegExport = b; } } /// Set this option to get the WMF export from PPT. usePPTImageExport = false; if (ConfigurationManager.AppSettings["PPTImageExport"] != null) { bool b; if (bool.TryParse(ConfigurationManager.AppSettings["PPTImageExport"], out b)) { Console.WriteLine("Using PPT for image export."); usePPTImageExport = b; } } }
/// <summary> /// The SlideImageGenerator can be shared by a set of modules. /// This allows us to avoid duplicating work of building slide images. /// Use this static method to get the instance, then run Process if /// the job has changed. /// </summary> /// <param name="job"></param> /// <param name="progressTracker"></param> /// <param name="log"></param> /// <returns></returns> public static SlideImageGenerator GetInstance(ArchiveTranscoderJob job, ProgressTracker progressTracker, LogMgr log) { if (instance == null) { instance = new SlideImageGenerator(job, progressTracker, log); } else { //Reset all properties instance.Job = job; instance.TheProgressTracker = progressTracker; instance.TheLogMgr = log; instance.TheRtDocuments = null; instance.TheSlideMessages = null; } return(instance); }
public SlideStreamMgr(ArchiveTranscoderJob job, ArchiveTranscoderJobSegment segment, LogMgr logMgr, double fps, int width, int height) { this.job = job; this.segment = segment; this.logMgr = logMgr; if (width > 0 && height > 0) { this.outputWidth = width; this.outputHeight = height; } this.ticksBetweenFrames = (long)((double)Constants.TicksPerSec / fps); uncompressedMT = getUncompressedMT(this.outputWidth, this.outputHeight, fps); cancel = false; initialized = false; pptInstalled = Utility.CheckPptIsInstalled(); if ((!DateTime.TryParse(segment.StartTime, out start)) || (!DateTime.TryParse(segment.EndTime, out end))) { throw(new System.Exception("Failed to parse start/end time")); } this.nextFrameTime = start.Ticks; format = Utility.StringToPresenterWireFormatType(segment.PresentationDescriptor.PresentationFormat); payload = Utility.formatToPayload(format); cname = segment.PresentationDescriptor.PresentationCname; slideImageMgr = new SlideImageMgr(format, this.outputWidth, this.outputHeight); //Get the start time for the entire conference and use that to get streams. long confStart = DatabaseUtility.GetConferenceStartTime(payload, cname, start.Ticks, end.Ticks); if (confStart <= 0) { logMgr.WriteLine("Warning: No conference exists in the database that matches this presentation: " + cname + " with PresentationFormat " + format.ToString()); logMgr.ErrorLevel = 7; confStart = start.Ticks; } //Get the relevant stream_id's and create DBStreamPlayers for each. streamIDs = DatabaseUtility.GetStreams(payload, segment.PresentationDescriptor.PresentationCname, null, confStart, end.Ticks); DateTime sdt = new DateTime(confStart); Debug.WriteLine("***Conference start: " + sdt.ToString() + " end: " + end.ToString()); if ((streamIDs == null) || (streamIDs.Length == 0)) { Debug.WriteLine("No presentation data found."); logMgr.WriteLine("Warning: No presentation data was found for the given time range for " + cname + " with PresentationFormat " + format.ToString()); logMgr.ErrorLevel = 7; streamPlayers = null; return; } streamPlayers = new DBStreamPlayer[streamIDs.Length]; for (int i = 0; i < streamIDs.Length; i++) { streamPlayers[i] = new DBStreamPlayer(streamIDs[i], confStart, end.Ticks, payload); } lookBehindDuration = 0; if (streamPlayers[0].Start < start) { lookBehindDuration = ((TimeSpan)(start - streamPlayers[0].Start)).TotalSeconds; } }