예제 #1
0
        public static IEnumerable <Chapter> GetChapters(string input)
        {
            Cutlist Cuts = new Cutlist();

            ProcessStartInfo psiProbe = new ProcessStartInfo($"{FFMPEG}ffprobe.exe")
            {
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false,
                CreateNoWindow         = false,
                Arguments = $"-show_chapters -print_format xml \"{input}\""
//				Arguments = $"{DEBUG}-show_chapters -print_format xml \"{input}\""
            };

            Process pProbe = Process.Start(psiProbe);

            Chapters      data;
            XmlSerializer ser = new XmlSerializer(typeof(Chapters));

//			string output = pProbe.StandardOutput.ReadToEnd();
            string error = pProbe.StandardError.ReadToEnd();

            pProbe.WaitForExit();
            data = (Chapters)ser.Deserialize(pProbe.StandardOutput);

            pProbe.Close();
            return(data.chapters);
        }
예제 #2
0
        public static void Trim2(string input, string mp4, Cutlist Cuts)
        {
            ProcessStartInfo psiFfmpeg = new ProcessStartInfo($"{FFMPEG}ffmpeg.exe")
            {
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                CreateNoWindow         = false
                                         //                ,
                                         //                Arguments = $"-i \"{input}\" {buildComplexFilter(Cuts)} f:\\temp\\cut.mp4"
            };

            if (Cuts.Count == 0)
            {
                //                psiFfmpeg.Arguments = $"-ss 6 - i \"{input}\" -vcodec copy -acodec copy -to {inputFile.Metadata.Duration.Subtract(TimeSpan.FromSeconds(13))} \"{mp4}\"";
            }
            else
            {
                double dur = Cuts.Sum(c => c.End - c.Start);
                psiFfmpeg.Arguments = $"-i \"{input}\" {buildComplexFilter(Cuts)} -c:v copy -c:a copy -t {dur} {mp4}";
            }

            Process pFfmpeg = Process.Start(psiFfmpeg);

            pFfmpeg.WaitForExit();
            pFfmpeg.Close();
        }
예제 #3
0
        private static string buildComplexFilter(Cutlist Cuts)
        {
            char   index  = 'a';
            string filter = $"-filter_complex \"";
            string concat = "";

            foreach (Cut c in Cuts)
            {
                filter += $"[0:v]trim=start={c.Start}:end={c.End - .1},setpts=PTS-STARTPTS[{index}v];";
                filter += $"[0:a]atrim=start={c.Start}:end={c.End - .1},asetpts=PTS-STARTPTS[{index}a];";
                concat += $"[{index}v][{index}a]";
                index++;
            }
            filter += $"{concat}concat=n={Cuts.Count}:v=1:a=1 [v] [a]\" -map \"[v]\" -map \"[a]\"";
            return(filter);
        }