Exemplo n.º 1
0
 private void Del()
 {
     if ((selectedRow != -1) && (selectedRow < Cuts.Count()))
     {
         Cuts.RemoveAt(selectedRow);
         MessengBool reset = new MessengBool();
         reset.DisableButton = true;
         Messenger.Default.Send(reset);
         ResetSelectedRow();
         if (Cuts.Count() == 0)
         {
             IsExportable = false;
         }
     }
 }
Exemplo n.º 2
0
        private void Export()
        {
            if (!Cuts.IsEmpty())
            {
                // check all the cuts

                /* for (int i = 0; i < Cuts.Count(); i++)
                 * {
                 *   if(Cuts.GetAt(i).Begin. > Cuts.GetAt(i).End)
                 *   {
                 *
                 *   }
                 *
                 *
                 * } */


                /*
                 * Create the split command with ffmpeg
                 */



                string resourcesFolderPath = Path.Combine(Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)).Parent.Parent.FullName, "Assets");
                string videoName           = Cuts.VideoPath.ToString().Split('/').Last().Split('.').First();



                //creation of the folder
                var process_cmd   = new System.Diagnostics.Process();
                var startInfo_cmd = new System.Diagnostics.ProcessStartInfo
                {
                    WindowStyle           = System.Diagnostics.ProcessWindowStyle.Normal,
                    FileName              = "cmd.exe",
                    RedirectStandardInput = true,
                    UseShellExecute       = false
                };

                process_cmd.StartInfo = startInfo_cmd;
                process_cmd.Start();

                string video_path = Cuts.VideoPath.LocalPath.Replace('\\', '/').Substring(0, Cuts.VideoPath.LocalPath.Replace('\\', '/').LastIndexOf('/') + 1);

                process_cmd.StandardInput.WriteLine("mkdir " + "\"" + video_path + videoName + "\"");

                process_cmd.WaitForExit(1000);
                process_cmd.Kill();



                for (int i = 0; i < Cuts.Count(); i++)
                {
                    //boucle d'export une itération par vidéo
                    var process   = new System.Diagnostics.Process();
                    var startInfo = new System.Diagnostics.ProcessStartInfo
                    {
                        WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
                        Arguments   = "-ss " + Cuts.GetAt(i).Begin.ToString().Substring(0, 8) + " -to " + Cuts.GetAt(i).End.ToString().Substring(0, 8) + " -i " + Cuts.VideoPath.LocalPath.Replace('\\', '/') + " -c copy " + video_path + videoName + "/" + Cuts.GetAt(i).Name + ".mp4",
                        FileName    = resourcesFolderPath + "\\" + "ffmpeg.exe",

                        RedirectStandardInput = false,
                        UseShellExecute       = true
                    };

                    /*process.StartInfo = startInfo;
                     * process.Start();*/
                    System.Diagnostics.Debug.WriteLine(resourcesFolderPath + "\\" + "ffmpeg.exe");
                    process = Process.Start(startInfo);
                    //System.Diagnostics.Debug.WriteLine("ffmpeg -ss " + Cuts.GetAt(i).Begin.ToString() + " -to " + Cuts.GetAt(i).End.ToString() + " -i " + Cuts.VideoPath.LocalPath + " -c copy " + " D:/Utilisateurs/Raphael/Vidéos/" + videoName + "/" + Cuts.GetAt(i).Name+".mp4");
                    // await Task.Delay(1000);
                    // process.StandardInput.WriteLine("cls");
                    // process.StandardInput.WriteLine("cd " +"\""+ resourcesFolderPath + "\"" );

                    // string command = "ffmpeg -ss " + Cuts.GetAt(i).Begin.ToString().Substring(0, 8) + " -to " + Cuts.GetAt(i).End.ToString().Substring(0, 8) + " -i " + Cuts.VideoPath.LocalPath.Replace('\\', '/') + " -c copy " + video_path + videoName + "/" + Cuts.GetAt(i).Name + ".mp4";

                    process.WaitForExit();



                    //export thumbnail
                    var thumb_location = video_path + videoName + "/" + Cuts.GetAt(i).Name + ".png";
                    //creation de la thumbnail
                    Bitmap image = GenerateThumb(i);
                    image.Save(thumb_location);
                    image.Dispose();
                }



                /*
                 * process.StandardInput.WriteLine("d:");
                 * process.StandardInput.WriteLine("mkdir \"D:/Utilisateurs/Raphael/AppData/Local/ffmpeg/" + videoName + "\"");
                 * process.StandardInput.WriteLine("cd D:/Program Files/ffmpeg-4.0-win64-static/bin");
                 */
            }
        }