public bool RenderFile(FileInfo fiVeg, FileInfo fiRendered, RenderTemplate renderTemplate, RenderStatusManager rsm, object dr)
        {
            DateTime renderStart = DateTime.Now;
            DateTime renderEnd;
            TimeSpan renderTime;

            rsm.Dialog.Hide(); // Temporarily hide because during load the UX kills it.
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStart, renderStart);
            if (myVegas.Project != null)
            {
                // No close method so create a clean new project without the ability to prompt for save of existing
                // and then open after that.
                myVegas.NewProject(false, false);
            }
            myVegas.UpdateUI();
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, "Loading");
            myVegas.OpenFile(fiVeg.FullName);
            myVegas.UpdateUI();
            myVegas.WaitForIdle();
            rsm.Dialog.Show();

            // Render
            RenderArgs ra = new RenderArgs();

            ra.OutputFile     = fiRendered.FullName;
            ra.RenderTemplate = renderTemplate;
            Timecode projectLength = GetProjectLength();

            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.ProjectLength, projectLength);
            ra.Length     = projectLength;
            ra.StartNanos = 0;

            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, "Rendering");
            RenderStatus status = myVegas.Render(ra);

            renderEnd  = DateTime.Now;
            renderTime = renderEnd - renderStart;
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderEnd, renderEnd);
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderTime, renderTime);
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, status.ToString());
            return(status == RenderStatus.Complete);
        }
Ejemplo n.º 2
0
        public void Render(ScriptPortal.Vegas.Vegas myVegas)
        {
            SetProgressBounds(Count);
            using (UndoBlock undo = new UndoBlock("Render tracks"))
            {
                for (int i = 0; i < Count; i++)
                {
                    var ri = this[i];

                    foreach (var trk in myVegas.Project.Tracks)
                    {
                        trk.Mute = !ri.Tracks.Contains(trk);
                    }

                    // padding
                    if (ri.RenderParams.GetParam <bool>(RenderTags.DoPadding))
                    {
                        if (ri.RenderTemplate.RendererID != myVegas.Renderers.FindByName("Wave (Microsoft)").ID)
                        {
                            ErrorLog(
                                String.Format(
                                    "The region {0} could not be padded. Padded rendering can only be performed on .WAV (PCM) files.",
                                    ri.Region.Label));
                        }
                        else
                        {
                            var paddingTime = Timecode.FromSeconds(ri.PaddingSeconds);
                            if (ri.Start - paddingTime < myVegas.Project.Ruler.StartTime)
                            {
                                ErrorLog(String.Format(
                                             "The region {0} could not be padded. Move your region further into the project.", ri.Region.Label));
                            }
                            else
                            {
                                ri.Start  -= paddingTime;
                                ri.Length += paddingTime;
                                ri.Length += paddingTime;
                            }
                        }
                    }

                    if (File.Exists(ri.FilePath) && ri.RenderParams.GetParam <bool>(RenderTags.DoReadonly))
                    {
                        // check readonly
                        var attr = File.GetAttributes(ri.FilePath);
                        if (attr.IsSet(FileAttributes.ReadOnly))
                        {
                            File.SetAttributes(ri.FilePath, attr & ~FileAttributes.ReadOnly);
                        }
                    }
                    SetProgress(i);
                    SetProgressStatus("Rendering " + ri.FilePath);
                    RenderStatus status = myVegas.Render(ri.FilePath, ri.RenderTemplate, ri.Start, ri.Length);
                    if (status != RenderStatus.Complete)
                    {
                        ErrorLog(String.Format("{0} raised error {1}", ri.FilePath, status.ToString()));
                    }
                    else
                    {
                        // file successfully rendered

                        // strip padding
                        if (ri.RenderParams.GetParam <bool>(RenderTags.DoPadding))
                        {
                            WaveFile.StripPadding(ri.FilePath, ri.PaddingSeconds);
                        }
                    }
                }
                foreach (ScriptPortal.Vegas.Track trk in myVegas.Project.Tracks)
                {
                    trk.Mute = false;
                }
                undo.Cancel = true;                 // we didn't really do anything useful.
            }
        }
Ejemplo n.º 3
0
        public static bool Send_Msg_To_Readies_Q(RenderStatus status, String item_id, DateTime beforeProcessingTime)
        {
            try
            {

                Dictionary<string, object> dict = new Dictionary<string, object>();

                DateTime current = DateTime.Now;
                TimeSpan duration = current - beforeProcessingTime;

                dict["item_id"] = item_id;
                //dict["url"] = @"http://" + Utils.my_ip + @"/testim/yofi_" + item_id + ".jpg";
                dict["url"] = @"http://s3.amazonaws.com/" + S3.bucketName + @"/" + item_id + ".jpg";
                dict["duration"] = Math.Round(duration.TotalSeconds, 3);
                dict["status"] = status.ToString();

                JavaScriptSerializer serializer = new JavaScriptSerializer(); //creating serializer instance of JavaScriptSerializer class
                string jsonString = serializer.Serialize((object)dict);

                SendMessageRequest sendMessageRequest = new SendMessageRequest();
                sendMessageRequest.QueueUrl = ready_Q_url; //URL from initial queue creation
                sendMessageRequest.MessageBody = Utils.EncodeTo64(jsonString);

                Console.WriteLine("Before sending ready msg(" + sendMessageRequest.MessageBody + ").");
                sqs.SendMessage(sendMessageRequest);
                Console.WriteLine("After sending ready msg(" + sendMessageRequest.MessageBody + ").");
            }
            catch (AmazonSQSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
                return false;
            }
            return true;
        }