Exemple #1
0
        public static void Trim(string input, string output)
        {
            string outDir = Path.GetDirectoryName(output);

            if (!Directory.Exists(outDir))
            {
                Directory.CreateDirectory(outDir);
            }
            Cutlist Cuts = GetCuts(input);

            //if (Cuts.Count ==0)
            //{
            //	double duration = Mpeg.GetDuration(input);
            //	Cuts.Add(new Cut() { Start = 6, End = duration - 7 });
            //}
            if (Cuts.Count > 0)
            {
                string meta = Mpeg.GetMetadata(input);
                Mpeg.RemoveChapters(meta);
                List <string> files = new List <string>();
                foreach (Cut cut in Cuts)
                {
                    string mp4 = GetTempMP4Name();
                    Mpeg.Trim(input, mp4, cut);
                    files.Add(mp4);
                }
                string temp = GetTempMP4Name();
                Mpeg.combine(files, output, meta, Cuts.Sum(c => c.End - c.Start));
//				Mpeg.addMeta(temp, output, meta);
                foreach (string file in files)
                {
                    File.Delete(file);
                }
                File.Delete(meta);
                File.Delete(temp);
            }
            else
            {
                double duration = Mpeg.GetDuration(input);
                Cut    cut      = new Cut()
                {
                    Start = 6, End = duration - 7
                };
                Mpeg.Trim(input, output, cut);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string foo = Environment.GetEnvironmentVariable("FFMPEGDir", EnvironmentVariableTarget.Machine);

            string file1 = @"H:\Recordings\TV\Valor\Season 1\Valor - s01e01 - Pilot  (Ep.101).mp4";
//			string file2 = @"H:\Recordings\TV\Blue Bloods\Season 8\Blue Bloods - s08e01 - Cutting Losses.mp4";
            string file3 = @"C:\temp\foo.mp4";

            IEnumerable <Chapter> pc1 = Mpeg.GetChapters(file1);
//			IEnumerable<Chapter> pc2 = Mpeg.GetChapters(file2);
            IEnumerable <Chapter> pc3 = Mpeg.GetChapters(file3);

            string m1 = Mpeg.GetMetadata(file1);
//			string m2 = Mpeg.GetMetadata(file2);
            string m3 = Mpeg.GetMetadata(file3);


            IEnumerable <Chapter> pcl = Mpeg.GetChapters(@"C:\temp\foo.mp4");

            Console.WriteLine("Hello World!");
        }