Exemplo n.º 1
0
 public static void WriteCutsToScript(string script, Cuts cuts, bool isAudio)
 {
     using (TextWriter s = new StreamWriter(File.Open(script, FileMode.Append)))
     {
         s.WriteLine(GetCutsScript(cuts, isAudio));
     }
 }
Exemplo n.º 2
0
        public Cuts clone()
        {
            Cuts copy = new Cuts(Style);

            copy.cuts      = new List <CutSection>(cuts);
            copy.Framerate = this.Framerate;
            return(copy);
        }
Exemplo n.º 3
0
 public static void WriteCutsToFile(string filename, Cuts cuts)
 {
     Debug.Assert(cuts.AllCuts.Count > 0);
     using (Stream s = File.Open(filename, FileMode.Create))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(Cuts));
         serializer.Serialize(s, cuts);
     }
 }
Exemplo n.º 4
0
        public static string GetCutsScript(Cuts cuts, bool isAudio)
        {
            using (StringWriter s = new StringWriter())
            {
                s.WriteLine();
                s.WriteLine("__film = last");

                if (isAudio) // We need to generate a fake video track to add
                {
                    s.WriteLine("__just_audio = __film");
                    s.WriteLine("__blank = BlankClip(length={0}, fps={1})", cuts.MinLength, Math.Round(cuts.Framerate, 3).ToString(new CultureInfo("en-us")));
                    s.WriteLine("__film = AudioDub(__blank, __film)");
                }

                int counter = 0;
                foreach (CutSection c in cuts.AllCuts)
                {
                    s.WriteLine("__t{0} = __film.trim({1}, {2})", counter, c.startFrame, c.endFrame);
                    counter++;
                }

                if (cuts.Style == TransitionStyle.NO_TRANSITION)
                {
                    for (int i = 0; i < counter; i++)
                    {
                        s.Write("__t{0} ", i);
                        if (i < counter - 1)
                        {
                            s.Write("++ ");
                        }
                    }
                    s.WriteLine();
                }
                else if (cuts.Style == TransitionStyle.FADE)
                {
                    for (int i = 0; i < counter; i++)
                    {
                        bool first = (i == 0);
                        bool last  = (i == (counter - 1));
                        s.Write(addFades("__t" + i, first, last, isAudio));
                        if (!last)
                        {
                            s.Write(" ++ ");
                        }
                    }
                    s.WriteLine();
                }
                else if (cuts.Style == TransitionStyle.DISSOLVE && counter != 0)
                {
                    string scriptlet = "__t" + (counter - 1);
                    for (int i = counter - 2; i >= 0; i--)
                    {
                        scriptlet = string.Format("__t{0}.Dissolve({1}, 60)", i, scriptlet);
                    }
                    s.WriteLine(scriptlet);
                }

                if (isAudio) // We now need to remove the dummy audio track
                {
                    // It will try to take the video from __just_audio, but there isn't any, so it just takes
                    // the audio stream from last
                    s.WriteLine("AudioDubEx(__just_audio, last)");
                }
                return(s.ToString());
            }
        }