Esempio n. 1
0
        private Boolean demuxChapters(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            try
            {
                LogBookController.Instance.addLogLine("Demuxing Chapters - Using ChapterXtractor", LogMessageCategories.Video);
                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingvobChapters"));

                MiniProcess proc = new DefaultProcess("Fetching chapters", fileDetails["name"][0] + "DeMuxingProcess");

                proc.initProcess();
                proc.setFilename(Path.Combine(DGIndex.getInstallPath(), "ChapterXtractor.exe"));

                string tempArg = "\"" + fileDetails["fileName"][0].Replace("_1", "_0").Replace(".VOB", ".IFO") + "\" " + "\"" + LocationManager.TempFolder + "chapters.txt\" -p5 -t1";
                proc.setArguments(tempArg);

                int exitCode = proc.startProcess();

                FileInfo tempChapFile = new FileInfo(LocationManager.TempFolder + "chapters.txt");

                if (tempChapFile.Length == 0)
                    File.Delete(LocationManager.TempFolder + "chapters.txt");

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (IOException)
            {
                return true;
            }
        }
Esempio n. 2
0
        private Boolean demuxSubs(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            LogBookController.Instance.addLogLine("Demuxing subs - Using Vobsub", LogMessageCategories.Video);
            LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingvobSubs"));

            MiniProcess proc = new DefaultProcess("Fetching subs", fileDetails["name"][0] + "DeMuxingProcess");

            proc.initProcess();

            string tempArg = "";

            StreamWriter streamWriter = new StreamWriter(LocationManager.TempFolder + fileDetails["name"][0] + ".vobsub");
            streamWriter.WriteLine(fileDetails["fileName"][0].Replace("_1", "_0").Replace(".VOB", ".IFO"));
            streamWriter.WriteLine(LocationManager.TempFolder + fileDetails["name"][0]);
            streamWriter.WriteLine("1");
            streamWriter.WriteLine("0");
            streamWriter.WriteLine("ALL");
            streamWriter.WriteLine("CLOSE");
            streamWriter.Close();

            proc.setFilename("C:\\WINDOWS\\system32\\rundll32.exe");

            tempArg = "VOBSUB.DLL,Configure " + LocationManager.TempFolder + fileDetails["name"][0] + ".vobsub";

            proc.setArguments(tempArg);
            int exitCode = proc.startProcess();

            LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));

            return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
        }
Esempio n. 3
0
        public Boolean demux(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            ExtApplication ogmtools = ToolsManager.Instance.getTool("ogmtools");

            LogBookController.Instance.addLogLine("Demuxing OGM - Using OgmTools", LogMessageCategories.Video);

            MiniProcess proc = new DefaultProcess("Demuxing OGM", fileDetails["name"][0] + "DeMuxingProcess");
            ProcessManager.Instance.Process = proc;

            proc.stdErrDisabled(false);
            proc.stdOutDisabled(false);

            try
            {
                if (!ogmtools.isInstalled())
                    ogmtools.download();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingMessage") + " OGM");
                proc.initProcess();

                proc.setFilename(Path.Combine(ogmtools.getInstallPath(), "OGMDemuxer.exe"));
                string tempArg = "tracks \"" + fileDetails["fileName"][0] + "\" -p " + tracks["video"][0].id + ":\"" + LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track." + Codec.Instance.getExtention(tracks["video"][0].codec) + "\"";
                tracks["video"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track." + Codec.Instance.getExtention(tracks["video"][0].codec);

                for (int i = 0; i < tracks["audio"].Length; i++)
                {
                    tracks["audio"][i].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Audio Track-" + i.ToString() + "." + Codec.Instance.getExtention(tracks["audio"][i].codec);
                    tempArg += " " + tracks["audio"][i].id + ":\"" + tracks["audio"][i].demuxPath + "\"";
                }

                for (int i = 0; i < tracks["subs"].Length; i++)
                {
                    tracks["subs"][i].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Subtitle Track-" + i.ToString() + "." + Codec.Instance.getExtention(tracks["subs"][i].codec);
                    tempArg += " " + tracks["subs"][i].id + ":\"" + tracks["subs"][i].demuxPath + "\"";
                }

                proc.setArguments(tempArg);
                int exitCode = proc.startProcess();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));

                if (!ProcessManager.hasProcessExitedCorrectly(proc, exitCode))
                    return false;

                if (File.Exists(LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track." + Codec.Instance.getExtention(tracks["video"][0].codec)))
                    return true;
                else
                    return false;
            }
            catch (KeyNotFoundException e)
            {
                LogBookController.Instance.addLogLine("Can't find codec: \r\n" + e.Message + "\r\n" + ErrorManager.fetchTrackData(tracks), LogMessageCategories.Error);

                return false;
            }
        }
Esempio n. 4
0
        private Boolean demuxFiles(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            try
            {
                LogBookController.Instance.addLogLine("Demuxing MKV - Using Mkvtoolnix", LogMessageCategories.Video);

                MiniProcess proc = new DefaultProcess(LanguageController.Instance.getLanguageString("demuxingMessage") + " MKV", fileDetails["name"][0] + "DeMuxingProcess");
                ProcessManager.Instance.Process = proc;

                if (!mkvtoolnix.isInstalled())
                    mkvtoolnix.download();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingMkv"));
                proc.initProcess();

                proc.setFilename(Path.Combine(mkvtoolnix.getInstallPath(), "mkvextract.exe"));
                string tempArg = tempArg = "tracks \"" + fileDetails["fileName"][0] + "\" ";

                tracks["video"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track" + "." + Codec.Instance.getExtention(tracks["video"][0].codec);

                tempArg += tracks["video"][0].id + ":\"" + tracks["video"][0].demuxPath + "\" ";


                for (int i = 0; i < tracks["audio"].Length; i++)
                {
                    tracks["audio"][i].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Audio Track-" + i.ToString() + "." + Codec.Instance.getExtention(tracks["audio"][i].codec);
                    tempArg += tracks["audio"][i].id + ":\"" + tracks["audio"][i].demuxPath + "\" ";
                }

                for (int i = 0; i < tracks["subs"].Length; i++)
                {
                    tracks["subs"][i].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Subtitle Track-" + i.ToString() + "." + Codec.Instance.getExtention(tracks["subs"][i].codec);
                    tempArg += tracks["subs"][i].id + ":\"" + tracks["subs"][i].demuxPath + "\" ";
                }

                proc.setArguments(tempArg);

                int exitCode = proc.startProcess();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (KeyNotFoundException e)
            {
                LogBookController.Instance.addLogLine("Can't find codec: \r\n" + e.Message + "\r\n" + ErrorManager.fetchTrackData(tracks), LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 5
0
        public Boolean index(SortedList<String, String[]> fileDetails, Track video)
        {
            ExtApplication dgavcindex = ToolsManager.Instance.getTool("DGAVCIndex");
            ExtApplication dgavcdecode = ToolsManager.Instance.getTool("DGAVCDecode");

            if (fileDetails["ext"][0].ToLower().Equals(".avi"))
                return true;
            try
            {
                MiniProcess proc = new DefaultProcess(LanguageController.Instance.getLanguageString("indexingAvc"), fileDetails["name"][0] + "DGAVCStepProcess");
                ProcessManager.Instance.Process = proc;

                proc.stdErrDisabled(false);
                proc.stdOutDisabled(false);
                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("indexingAvc"));
                LogBookController.Instance.addLogLine("Started Indexing AVC", LogMessageCategories.Video);

                proc.initProcess();

                if (!dgavcindex.isInstalled())
                    dgavcindex.download();
                if (!dgavcdecode.isInstalled())
                    dgavcdecode.download();

                proc.setFilename(Path.Combine(dgavcindex.getInstallPath(), "DGAVCIndex.exe"));
                string dgaFile = LocationManager.TempFolder + fileDetails["name"][0] + ".dga";
                proc.setArguments("-i \"" + video.demuxPath + "\" -o \"" + dgaFile + "\" -a -h -e");

                int exitCode = proc.startProcess();
                video.demuxPath = dgaFile;

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("indexingAvcCompleted"));
                LogBookController.Instance.addLogLine("Finished Indexing AVC", LogMessageCategories.Video);

                if (!ProcessManager.hasProcessExitedCorrectly(proc, exitCode))
                    return false;

                if (File.Exists(dgaFile))
                    return true;
                else
                    return false;
            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error indexing AVC. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 6
0
        public Boolean decode(SortedList<String, String[]> fileDetails, int i, Track audio)
        {
            try
            {
                ExtApplication flac = ToolsManager.Instance.getTool("flac");

                MiniProcess proc = new DefaultProcess("Decoding Audio Track (ID = " + (i) + ")", fileDetails["name"][0] + "AudioDecodingProcess");

                ProcessManager.Instance.Process = proc;
                proc.initProcess();
                proc.stdErrDisabled(true);
                proc.stdOutDisabled(true);

                LogBookController.Instance.addLogLine("Decoding Flac - Using flac", LogMessageCategories.Video);
                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("audioDecodingMessage"));

                String decodedAudio = LocationManager.TempFolder + fileDetails["name"][0] + "-Decoded Audio Track-" + i.ToString() + ".wav";

                if (!flac.isInstalled())
                    flac.download();

                proc.setFilename(Path.Combine(flac.getInstallPath(), "flac.exe"));
                proc.setArguments("-d -o \"" + decodedAudio + "\" \"" + audio.demuxPath + "\"");

                int exitCode = proc.startProcess();

                audio.demuxPath = decodedAudio;

                LogBookController.Instance.addLogLine("Decoding completed", LogMessageCategories.Video);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error decoding audio with Flac. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);

                return false;
            }
        }
Esempio n. 7
0
        public bool encode(SortedList<String, String[]> fileDetails, int i, Track audio, SortedList<String, String> EncOpts)
        {
            try
            {
                ExtApplication lame = ToolsManager.Instance.getTool("lame");

                MiniProcess proc = new DefaultProcess(LanguageController.Instance.getLanguageString("audioEncodingTrack") + " (ID = " + (i) + ")", fileDetails["name"][0] + "AudioEncodingProcess");
                ProcessManager.Instance.Process = proc;

                proc.stdErrDisabled(true);
                proc.stdOutDisabled(false);

                LogBookController.Instance.addLogLine("Encoding to Lame MP3", LogMessageCategories.Video);

                proc.initProcess();

                proc.setFilename(Path.Combine(lame.getInstallPath(), "lame.exe"));

                if (!lame.isInstalled())
                    lame.download();

                audio.encodePath = LocationManager.TempFolder + Path.GetFileNameWithoutExtension(audio.demuxPath) + "_output.mp3";
                proc.setArguments("--abr " + EncOpts["audbr"] + " -h \"" + audio.demuxPath + "\" \"" + audio.encodePath + "\"");

                int exitCode = proc.startProcess();

                LogBookController.Instance.addLogLine("Encoding audio completed", LogMessageCategories.Video);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);

            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error encoding audio to Lame MP3. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 8
0
        public Boolean mux(SortedList<String, String[]> fileDetails, SortedList<String, String> encOpts, SortedList<String, Track[]> fileTracks)
        {
            try
            {
                ExtApplication mkvtoolnix = ToolsManager.Instance.getTool("mkvtoolnix");

                MiniProcess proc = new DefaultProcess("Muxing to MKV", fileDetails["name"][0] + "FileMuxingProcess");
                proc.stdErrDisabled(false);
                proc.stdOutDisabled(false);
                proc.initProcess();

                LogBookController.Instance.addLogLine("Muxing to MKV", LogMessageCategories.Video);
                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("muxingMessage") + " MKV");

                string args;

                try
                {
                    float dar = int.Parse(encOpts["width"]) / int.Parse(encOpts["height"]);
                    float par = int.Parse(fileDetails["width"][0]) / int.Parse(fileDetails["height"][0]);

                    if (dar != par & encOpts["sizeopt"] != "0")
                    {

                        encOpts["width"] = (int.Parse(encOpts["width"]) * dar).ToString();
                    }
                }
                catch
                {
                    encOpts["width"] = fileDetails["width"][0];
                    encOpts["height"] = fileDetails["height"][0];
                }

                encOpts.Add("outfile", encOpts["outDIR"] + fileDetails["name"][0] + "_output.mkv");

                if (!mkvtoolnix.isInstalled())
                    mkvtoolnix.download();

                proc.setFilename(Path.Combine(mkvtoolnix.getInstallPath(), "mkvmerge.exe"));

                string arg1 = "";

                if (encOpts.ContainsKey("vfr"))
                    if (!String.IsNullOrEmpty(encOpts["vfr"]))
                        arg1 += "--timecodes 0:\"" + encOpts["vfr"] + "\" ";

                if (encOpts["advertdisabled"] == "False")
                    arg1 += "--title \"Encoded with MiniCoder\" ";

                if (File.Exists(LocationManager.TempFolder + "chapters.xml"))
                    arg1 += "--chapters \"" + LocationManager.TempFolder + "chapters.xml\" ";

                if (File.Exists(LocationManager.TempFolder + "chapters.txt"))
                    arg1 += "--chapters \"" + LocationManager.TempFolder + "chapters.txt\" ";

                try
                {
                    args = "-o \"" + encOpts["outfile"] + "\" --default-duration 0:" + fileDetails["fps"][0] + "fps --display-dimensions 0:" + encOpts["width"] + "x" + encOpts["height"] + " " + arg1 + "-d 0 -A -S \"" + fileTracks["video"][0].encodePath + "\" ";
                }
                catch
                {
                    LogBookController.Instance.addLogLine("Error parsing fps", LogMessageCategories.Error);
                    return false;
                }


                for (int i = 0; i < fileTracks["audio"].Length; i++)
                {
                    if (encOpts["audcodec"] == "0")
                    {
                        args += "--aac-is-sbr 1:1 ";
                        args += "--language 1:" + Language.Instance.getExtention(fileTracks["audio"][i].language) + " --track-name 1:\"" + fileTracks["audio"][i].title + "\" -a 1 -D -S \"" + fileTracks["audio"][i].encodePath + "\" ";
                    }
                    else
                        args += "--language 0:" + Language.Instance.getExtention(fileTracks["audio"][i].language) + " --track-name 0:\"" + fileTracks["audio"][i].title + "\" -a 0 -D -S \"" + fileTracks["audio"][i].encodePath + "\" ";
                }

                for (int i = 0; i < fileTracks["subs"].Length; i++)
                {
                    args += "--language 0:" + Language.Instance.getExtention(fileTracks["subs"][i].language) + " --track-name 0:\"" + fileTracks["subs"][i].title + "\" -s 0 -A -D \"" + fileTracks["subs"][i].demuxPath + "\" ";
                }

                if (fileTracks.ContainsKey("attachments"))
                {
                    for (int i = 0; i < fileTracks["attachments"].Length; i++)
                    {
                        if (File.Exists(fileTracks["attachments"][i].demuxPath))
                            args += "--attachment-mime-type application/x-truetype-font --attachment-name \"" + fileTracks["attachments"][i].title + "\" --attach-file \"" + fileTracks["attachments"][i].demuxPath + "\" ";
                    }
                }

                args += "--track-order 0:0,";

                for (int i = 0; i < fileTracks["audio"].Length; i++)
                    args += (i + 1).ToString() + ":1,";

                int step = fileTracks["audio"].Length + 1;

                for (int i = 0; i < fileTracks["subs"].Length; i++)
                    args += (i + step).ToString() + ":0,";

                proc.setArguments(args);

                int exitCode = proc.startProcess();

                LogBookController.Instance.addLogLine("Muxing Completed", LogMessageCategories.Video);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }

            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error muxing to Matroska. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 9
0
        public Boolean demux(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            ExtApplication mp4box = ToolsManager.Instance.getTool("mp4box");

            LogBookController.Instance.addLogLine("Demuxing MP4 - Using mp4box", LogMessageCategories.Video);

            int exitCode = 0;
            MiniProcess proc = new DefaultProcess("Demuxing MP4", fileDetails["name"][0] + "DeMuxingProcess");

            ProcessManager.Instance.Process = proc;
            proc.stdErrDisabled(false);
            proc.stdOutDisabled(false);

            try
            {
                if (!mp4box.isInstalled())
                    mp4box.download();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingmp4Video"));

                proc.initProcess();
                proc.setFilename(Path.Combine(mp4box.getInstallPath(), "MP4Box.exe"));

                string tempArg;
                switch (tracks["video"][0].codec)
                {
                    case "DIV3":
                    case "XVID":
                    case "DIVX":
                    case "DX50":
                    case "DX60":
                    case "V_MS/VFW/FOURCC":
                    case "20":
                        tracks["video"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track.avi";
                        tempArg = "\"" + fileDetails["fileName"][0] + "\" -avi 1 -out \"" + LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track\"";
                        break;
                    default:
                        tracks["video"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track." + Codec.Instance.getExtention(tracks["video"][0].codec);
                        tempArg = "\"" + fileDetails["fileName"][0] + "\" -raw 1 -out \"" + LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track." + Codec.Instance.getExtention(tracks["video"][0].codec) + "\"";
                        break;
                }
                proc.setArguments(tempArg);
                exitCode = proc.startProcess();
                if (proc.getAbandonStatus())
                    return false;
                if (exitCode != 0)
                    return false;

                if (tracks["audio"].Length == 0)
                    return true;

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingmp4Audio"));

                tracks["audio"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Audio Track-" + "1" + "." + Codec.Instance.getExtention(tracks["audio"][0].codec);
                tempArg = "\"" + fileDetails["fileName"][0] + "\" -raw 2 -out \"" + tracks["audio"][0].demuxPath + "\"";
                proc.setArguments(tempArg);
                exitCode = proc.startProcess();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (KeyNotFoundException e)
            {
                LogBookController.Instance.addLogLine("Can't find codec: \r\n" + e.Message + "\r\n" + ErrorManager.fetchTrackData(tracks), LogMessageCategories.Error);

                return false;
            }
        }
Esempio n. 10
0
        private Boolean demuxAttachments(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {

            if (fileDetails["skipattachments"][0] == "True")
                return true;

            LogBookController.Instance.addLogLine("Fetching MKV Attachments - Using MkvInfo", LogMessageCategories.Video);

            MiniProcess proc = new AttachmentProcess();
            ProcessManager.Instance.Process = proc;

            LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingMkvAttachments"));
            proc.initProcess();

            proc.setFilename(Path.Combine(mkvtoolnix.getInstallPath(), "mkvinfo.exe"));
            proc.setArguments("\"" + fileDetails["fileName"][0] + "\"");

            proc.startProcess();
            string outputLog = proc.getAdditionalOutput();

            string[] split = Regex.Split(outputLog, "\\+ File name: ");

            string temp;

            Track[] attachments = new Track[split.Length - 1];

            char[] sep1 = { ':' };
            char[] sep2 = { '\r' };
            try
            {
                int start = outputLog.IndexOfAny(sep1, outputLog.IndexOf("Display width")) + 2;
                int end = outputLog.IndexOfAny(sep2, outputLog.IndexOf("Display width"));
                temp = outputLog.Substring(start, end - start);
                int width = int.Parse(temp);

                start = outputLog.IndexOfAny(sep1, outputLog.IndexOf("Display height")) + 2;
                end = outputLog.IndexOfAny(sep2, outputLog.IndexOf("Display height"));
                temp = outputLog.Substring(start, end - start);
                int height = int.Parse(temp);


                LogBookController.Instance.addLogLine("Number of attachments: " + (split.Length - 1).ToString(), LogMessageCategories.Video);

                if ((split.Length - 1) == 0)
                    return true;

                for (int i = 1; i < split.Length; i++)
                    attachments[i - 1] = new Attachment(LocationManager.TempFolder + split[i].Substring(0, split[i].IndexOf("\r\n")), split[i].Substring(0, split[i].IndexOf("\r\n")));

                proc = new DefaultProcess("Demuxing Attachments", fileDetails["name"][0] + "AttachmentFetching");
                proc.initProcess();

                proc.setFilename(Path.Combine(mkvtoolnix.getInstallPath(), "mkvextract.exe"));
                string tempArg = "attachments \"" + fileDetails["fileName"][0] + "\"";

                for (int i = 1; i <= attachments.Length; i++)
                    tempArg += " " + i.ToString() + ":\"" + attachments[i - 1].demuxPath + "\"";

                proc.setArguments(tempArg);
                int exitCode = proc.startProcess();

                tracks.Add("attachments", attachments);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch
            {
                LogBookController.Instance.addLogLine("Error demuxing attachments!", LogMessageCategories.Error);

                return false;
            }
        }
Esempio n. 11
0
        public Boolean demux(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            ExtApplication vdubmod = ToolsManager.Instance.getTool("VirtualDubMod");

            LogBookController.Instance.addLogLine("Demuxing AVI - Using Vdubmod", LogMessageCategories.Video);

            MiniProcess proc = new DefaultProcess("Demuxing Avi", fileDetails["name"][0] + "DeMuxingProcess");
            ProcessManager.Instance.Process = proc;

            proc.stdErrDisabled(false);
            proc.stdOutDisabled(false);

            try
            {
                if (!vdubmod.isInstalled())
                    vdubmod.download();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingMessage") + " AVI Tracks");

                proc.initProcess();

                LogBookController.Instance.addLogLine("Writing VirtualDub Script", LogMessageCategories.Video);

                StreamWriter vcf = File.CreateText(LocationManager.TempFolder + fileDetails["name"][0] + "_demux.vcf"); ;
                string temp = "VirtualDub.Open(\"" + fileDetails["fileName"][0].Replace("\\", "\\\\") + "\",\"\",0);\r\n";

                tracks["video"][0].demuxPath = fileDetails["fileName"][0];

                for (int i = 0; i < tracks["audio"].Length; i++)
                {
                    tracks["audio"][i].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "-Audio Track-" + i.ToString() + "." + Codec.Instance.getExtention(tracks["audio"][i].codec);
                    temp += ("VirtualDub.stream[" + i.ToString() + "].Demux(\"" + tracks["audio"][i].demuxPath.Replace("\\", "\\\\") + "\");");
                }

                LogBookController.Instance.addLogLine(temp, LogMessageCategories.Video);

                vcf.WriteLine(temp);
                vcf.Close();

                proc.setFilename(Path.Combine(vdubmod.getInstallPath(), "VirtualDubMod.exe"));
                proc.setArguments("/s\"" + LocationManager.TempFolder + fileDetails["name"][0] + "_demux.vcf\" /x");

                proc.startProcess();

                if (proc.getAbandonStatus())
                {
                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingAbortedMessage"));
                    return false;
                }
                else
                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));
                try
                {
                    if (File.Exists(LocationManager.TempFolder + fileDetails["name"][0] + "-Audio Track-0." + Codec.Instance.getExtention(tracks["audio"][0].codec)))
                        return true;
                    else
                        return false;
                }
                catch
                {
                    return false;
                }
            }
            catch (KeyNotFoundException e)
            {
                LogBookController.Instance.addLogLine("Can't find codec: \r\n" + e.Message + "\r\n" + ErrorManager.fetchTrackData(tracks), LogMessageCategories.Error);
             
                return false;
            }

        }
Esempio n. 12
0
        private Boolean demuxFile(SortedList<String, String[]> fileDetails, SortedList<String, Track[]> tracks)
        {
            MiniProcess proc = new DefaultProcess("Indexing VOB", fileDetails["name"][0] + "DeMuxingProcess");
            ProcessManager.Instance.Process = proc;
            proc.stdErrDisabled(false);
            proc.stdOutDisabled(false);

            if (!DGIndex.isInstalled())
                DGIndex.download();
            string tempArg;

            LogBookController.Instance.addLogLine("Demuxing VOB - Using DGIndex", LogMessageCategories.Video);
            LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingVob"));

            proc.initProcess();
            proc.setFilename(Path.Combine(DGIndex.getInstallPath(), "DGIndex.exe"));

            tracks["video"][0].demuxPath = LocationManager.TempFolder + fileDetails["name"][0] + "." + Codec.Instance.getExtention(tracks["video"][0].codec);
            tempArg = "-SD=< -AIF=<" + fileDetails["fileName"][0] + "< -OF=<" + LocationManager.TempFolder + fileDetails["name"][0] + "< -exit -hide -OM=2 -TN=80";

            proc.setArguments(tempArg);
            int exitCode = proc.startProcess();

            DirectoryInfo info = new DirectoryInfo(LocationManager.TempFolder);
            int count = 0;

            foreach (FileInfo fInfo in info.GetFiles())
            {
                if (fInfo.Extension == ".ac3")
                    tracks["audio"][count++].demuxPath = fInfo.FullName;
            }

            LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("demuxingCompleteMessage"));

            return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
        }
Esempio n. 13
0
        public Boolean analyse(SortedList<String, String> encOpts, SortedList<String, String[]> fileDetails)
        {
            try
            {
                ExtApplication vfr = ToolsManager.Instance.getTool("mkv2vfr");
                ExtApplication vfrMP4 = ToolsManager.Instance.getTool("DtsEdit");

                if (fileDetails["ext"][0].ToLower() == "mkv" && encOpts.ContainsKey("vfr"))
                {
                    LogBookController.Instance.addLogLine("Started analysing VFR", LogMessageCategories.Video);

                    MiniProcess proc = new DefaultProcess("Analysing for VFR", fileDetails["name"][0] + "VFRAnalyseProcess");
                    ProcessManager.Instance.Process = proc;

                    if (!vfr.isInstalled())
                        vfr.download();

                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("vfrParsing"));
                    proc.initProcess();

                    proc.setFilename(Path.Combine(vfr.getInstallPath(), "mkv2vfr.exe"));
                    proc.setArguments("\"" + fileDetails["fileName"][0] + "\" \"" + LocationManager.TempFolder + fileDetails["name"][0] + "-Video Track.avi\" \"" + LocationManager.TempFolder + "timecode.txt\"");

                    int exitCode = proc.startProcess();


                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("vfrParsingCompleted"));

                    if (!ProcessManager.hasProcessExitedCorrectly(proc, exitCode))
                        return false;

                    if (!File.Exists(LocationManager.TempFolder + "timecode.txt"))
                        return false;

                    encOpts["vfr"] = LocationManager.TempFolder + "timecode.txt";
                }
                else if (fileDetails["ext"][0].ToLower() == "mp4" && encOpts.ContainsKey("vfr"))
                {
                    LogBookController.Instance.addLogLine("Started analysing VFR", LogMessageCategories.Video);
                    MiniProcess proc = new DefaultProcess("Analysing for VFR", fileDetails["name"][0] + "VFRAnalyseProcess");
                    ProcessManager.Instance.Process = proc;

                    if (!vfrMP4.isInstalled())
                        vfrMP4.download();

                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("vfrParsing"));
                    proc.initProcess();

                    proc.setFilename(Path.Combine(vfrMP4.getInstallPath(), "DtsEdit.exe"));
                    proc.setArguments("\"" + fileDetails["fileName"][0] + "\"");

                    int exitCode = proc.startProcess();

                    File.Move(fileDetails["fileName"][0] + "_timecode.txt", LocationManager.TempFolder + "timecode.txt");


                    LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("vfrParsingCompleted"));

                    if (!ProcessManager.hasProcessExitedCorrectly(proc, exitCode))
                        return false;

                    if (!File.Exists(LocationManager.TempFolder + "timecode.txt"))
                        return false;

                    encOpts["vfr"] = LocationManager.TempFolder + "timecode.txt";
                }
                return true;
            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error analysing VFR. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 14
0
        public Boolean mux(SortedList<String, String[]> fileDetails, SortedList<String, String> encOpts, SortedList<String, Track[]> fileTracks)
        {
            try
            {
                ExtApplication ffmpeg = ToolsManager.Instance.getTool("ffmpeg");

                LogBookController.Instance.addLogLine("Muxing to AVI", LogMessageCategories.Video);

                MiniProcess proc = new DefaultProcess("Muxing to AVI", fileDetails["name"][0] + "FileMuxingProcess");
                proc.stdErrDisabled(true);
                proc.stdOutDisabled(false);
                proc.initProcess();

                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("muxingMessage") + " avi...");
                string args;

                try
                {
                    float dar = int.Parse(encOpts["width"]) / int.Parse(encOpts["height"]);
                    float par = int.Parse(fileDetails["width"][0]) / int.Parse(fileDetails["height"][0]);

                    if (dar != par & encOpts["sizeopt"] != "0")
                    {

                        encOpts["width"] = (int.Parse(encOpts["width"]) * dar).ToString();
                    }
                }
                catch
                {
                    encOpts["width"] = fileDetails["width"][0];
                    encOpts["height"] = fileDetails["height"][0];
                }

                encOpts.Add("outfile", encOpts["outDIR"] + fileDetails["name"][0] + "_output.avi");

                if (!ffmpeg.isInstalled())
                    ffmpeg.download();

                proc.setFilename(Path.Combine(ffmpeg.getInstallPath(), "ffmpeg.exe"));

                args = "-i \"" + fileTracks["video"][0].encodePath + "\" -vcodec copy -r " + fileDetails["fps"][0] + " -s " + encOpts["width"] + "x" + encOpts["height"] + " ";

                for (int i = 0; i < fileTracks["audio"].Length; i++)
                {
                    args += "-i \"" + fileTracks["audio"][i].encodePath + "\" -acodec copy ";
                }

                args += "\"" + encOpts["outfile"] + "\"";

                proc.setArguments(args);

                int exitCode = proc.startProcess();


                LogBookController.Instance.setInfoLabel("Muxing Complete");
                LogBookController.Instance.addLogLine("Muxing completed", LogMessageCategories.Video);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error muxing to avi. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }
Esempio n. 15
0
        public Boolean mux( SortedList<String, String[]> fileDetails, SortedList<String, String> encOpts, SortedList<String, Track[]> fileTracks)
        {
            try
            {
                ExtApplication mp4box = ToolsManager.Instance.getTool("mp4box");

                MiniProcess proc = new DefaultProcess("Muxing to MP4", fileDetails["name"][0] + "FileMuxingProcess");
                proc.stdErrDisabled(false);
                proc.stdOutDisabled(false);
                proc.initProcess();

                LogBookController.Instance.addLogLine("Muxing to MP4", LogMessageCategories.Video);
                LogBookController.Instance.setInfoLabel(LanguageController.Instance.getLanguageString("muxingMessage") + " MP4");

                string args;

                try
                {
                    float dar = int.Parse(encOpts["width"]) / int.Parse(encOpts["height"]);
                    float par = int.Parse(fileDetails["width"][0]) / int.Parse(fileDetails["height"][0]);

                    if (dar != par & encOpts["sizeopt"] != "0")
                    {

                        encOpts["width"] = (int.Parse(encOpts["width"]) * dar).ToString();
                    }
                }
                catch
                {
                    encOpts["width"] = fileDetails["width"][0];
                    encOpts["height"] = fileDetails["height"][0];

                }

                encOpts.Add("outfile", encOpts["outDIR"] + fileDetails["name"][0] + "_output.mp4");

                if (!mp4box.isInstalled())
                    mp4box.download();

                proc.setFilename(Path.Combine(mp4box.getInstallPath(), "mp4box.exe"));

                args = "-fps " + fileDetails["fps"][0] + " -add \"" + fileTracks["video"][0].encodePath + "#video:name=Video\" ";

                for (int i = 0; i < fileTracks["audio"].Length; i++)
                {
                    args += "-add \"" + fileTracks["audio"][i].encodePath + ":lang=" + Language.Instance.getExtention(fileTracks["audio"][i].language) + "\" ";
                }

                if (encOpts["hardsubmp4"] == "0")
                {
                    for (int i = 0; i < fileTracks["subs"].Length; i++)
                    {
                        args += "-add \"" + fileTracks["subs"][i].demuxPath + ":lang=" + Language.Instance.getExtention(fileTracks["subs"][i].language) + "\" ";

                    }
                }
                args += "-new \"" + encOpts["outfile"] + "\"";

                proc.setArguments(args);
                if (proc.getAbandonStatus())
                    return false;

                int exitCode = proc.startProcess();

                LogBookController.Instance.addLogLine("Muxing completed", LogMessageCategories.Video);

                return ProcessManager.hasProcessExitedCorrectly(proc, exitCode);
            }
            catch (Exception error)
            {
                LogBookController.Instance.addLogLine("Error muxing to MP4. (" + error.Source + ", " + error.Message + ", " + error.Data + ", " + error.ToString() + ")", LogMessageCategories.Error);
                return false;
            }
        }