Пример #1
0
        // 0: succes, 1: error, 2: no movement in file
        public int WriteVideo(ProgressStorage progressStorage)
        {
            int movementSomewhere = 1;

            // create txt file that will be used to join all videos
            temporaryFiles = new List <String>();
            String txtPath = outputfolder + "\\output_temptxtfile.txt";

            temporaryFiles.Add(txtPath); // add to files that will be removed after execution
            StreamWriter outputtxt = new StreamWriter(txtPath, false);

            // convert to mp4 in original quality, create subparts and add then to the outputtxt
            for (int i = 0; i < filelist.Length; i++)
            {
                String toDeleteFile = convertPart(filelist[i]); // no result needed, because if this failed, next one will fail as well
                int    result       = cutParts(toDeleteFile, trackerlist[i], outputtxt);
                if (result == 1)                                // it failed
                {
                    // remove all temporary objects here (close txt first)
                    outputtxt.Close();
                    clearFiles(temporaryFiles);
                    progressStorage.resetGeneration(); // update progressStorage
                    return(1);                         // something failed
                }
                else if (result == 0)
                {
                    // if we get in to this part at least once, it means there is movement in some of the files
                    movementSomewhere = 0;
                }
                clearFile(toDeleteFile);                  // delete temp file
                progressStorage.generationFileFinished(); // update progressStorage
            }
            int result2;

            outputtxt.Close();
            if (movementSomewhere == 0)
            {
                // execute the command to join the subfiles
                result2 = joinParts(txtPath);
            }
            else
            {
                result2 = 2;
            }
            // remove all temporary files
            clearFiles(temporaryFiles);
            if (result2 != 1)
            {
                progressStorage.generationFileFinished(); // update progressStorage
            }
            else
            {
                progressStorage.resetGeneration(); // update progressStorage
            }
            return(result2);
        }
 // 0: succes, 1: error, 2: no movement in file
 public int WriteVideo(ProgressStorage progressStorage)
 {
     int movementSomewhere = 1;
     // create txt file that will be used to join all videos
     temporaryFiles = new List<String>();
     String txtPath = outputfolder + "\\output_temptxtfile.txt";
     temporaryFiles.Add(txtPath); // add to files that will be removed after execution
     StreamWriter outputtxt = new StreamWriter(txtPath, false);
     // convert to mp4 in original quality, create subparts and add then to the outputtxt
     for (int i = 0; i < filelist.Length; i++)
     {
         String toDeleteFile = convertPart(filelist[i]); // no result needed, because if this failed, next one will fail as well
         int result = cutParts(toDeleteFile, trackerlist[i], outputtxt);
         if(result == 1) // it failed
         {
             // remove all temporary objects here (close txt first)
             outputtxt.Close();
             clearFiles(temporaryFiles);
             progressStorage.resetGeneration(); // update progressStorage
             return 1; // something failed
         } else if (result == 0)
         {
             // if we get in to this part at least once, it means there is movement in some of the files
             movementSomewhere = 0;
         }
         clearFile(toDeleteFile); // delete temp file
         progressStorage.generationFileFinished(); // update progressStorage
     }
     int result2;
     outputtxt.Close();
     if(movementSomewhere == 0)
     {
         // execute the command to join the subfiles
         result2 = joinParts(txtPath);
     } else
     {
         result2 = 2;
     }
     // remove all temporary files
     clearFiles(temporaryFiles);
     if(result2 != 1)
     {
         progressStorage.generationFileFinished(); // update progressStorage
     }
     else
     {
         progressStorage.resetGeneration(); // update progressStorage
     }
     return result2;
 }