示例#1
0
        /// <summary>
        /// 最初のavsファイルの作成
        /// </summary>
        private void MakeAvs()
        {
            string strAvsName = Path.Combine(strInputFilePathWithoutExtension + ".avs");
            Dictionary <string, object> dicAvsContents = new Dictionary <string, object>();

            // DGDecode.dllのパス
            string strDgDecodePath = Path.Combine(Program.CurrentDirectory, XDOCUMENT_CONFIG_LIBRARY.ReadConfig("DgDecode", "Path"));

            dicAvsContents.Add("LoadPlugin", strDgDecodePath);
            dicAvsContents.Add("SetMemoryMax", 256);
            dicAvsContents.Add("DGDecode_MPEG2Source", strInputFilePathWithoutExtension + ".d2v");
            dicAvsContents.Add("WavSource", strInputFilePathWithoutExtension + ".wav");
            dicAvsContents.Add("interlaced", "true");

            using (StreamWriter swAvs = new StreamWriter(new FileStream(strAvsName, FileMode.Append), Encoding.GetEncoding(932)))
            {
                // AVSファイルは文字コードがCP932でないとアプリケーションが読み込めない。

                swAvs.WriteLine("SetMemoryMax(" + dicAvsContents["SetMemoryMax"] + ")");
                swAvs.WriteLine("LoadPlugin(" + "\"" + dicAvsContents["LoadPlugin"] + "\"" + ")");
                swAvs.WriteLine("vSrc = DGDecode_MPEG2Source(" + "\"" + dicAvsContents["DGDecode_MPEG2Source"] + "\")");
                swAvs.WriteLine("vSrc = KillAudio(vSrc)");
                swAvs.WriteLine("aSrc = WavSource(" + "\"" + dicAvsContents["WavSource"] + "\")");
                swAvs.WriteLine("aSrc = KillVideo(aSrc)");
                swAvs.WriteLine("AudioDubEx(vSrc,aSrc)");
                swAvs.WriteLine("ConvertToYUY2(interlaced = " + dicAvsContents["interlaced"] + ")");
            }
        }
示例#2
0
        /// <summary>
        /// 録画ディレクトリ内のすべてのTSファイルを順次アプリケーションに引き渡していく
        /// </summary>
        /// <returns>実行成否</returns>
        public void EncodeMovie()
        {
            // DGIndexの処理終了 → DGIndexが出力したAACを削除
            // (放送局がTOKYO MXのファイルのAACファイルは壊れているので別途ts2aac.exeにて取得する)
            // 一つのファイルに二つの放送波が混在しているため?

            string str = null;

            str.Replace("", "fff");

            foreach (string file in tsFiles.FileNameWithoutExtension)
            {
                // 録画ディレクトリ内のTSファイルをそれぞれ処理する

                // グローバル変数に現在処理している.tsファイルを登録

                strInputFilePath = Path.Combine(PATH_DIR_WORK, "temp" + ".ts");
                strInputFilePathWithoutExtension = Path.Combine(PATH_DIR_WORK, "temp");

                strOriginalFilePath = Path.Combine(PATH_DIR_WORK, file + ".ts");
                strOriginalFilePathWithoutExtension = Path.Combine(PATH_DIR_WORK, file);

                Dictionary <string, ExternalAppSettings> dicSettings = new Dictionary <string, ExternalAppSettings>()
                {
                    {
                        // DGIndex.exeでTSをD2Vに
                        "DgIndex"
                        , new ExternalAppSettings(
                            "DgIndex"
                            , strInputFilePathWithoutExtension
                            , DeleteAAC
                            , strInputFilePathWithoutExtension)
                    },
                    {
                        // ts2aac.exeでtsファイルから壊れていないaacファイルを取得する
                        "Ts2Aac"
                        , new ExternalAppSettings(
                            "Ts2Aac"
                            , strInputFilePathWithoutExtension
                            , RenameAAC
                            , strInputFilePathWithoutExtension)
                    },
                    {
                        // ToWaveでts2aac.exeから再取得したaacファイルをwavファイルへ変換
                        "ToWave"
                        , new ExternalAppSettings(
                            "ToWave"
                            , strInputFilePathWithoutExtension
                            // avsファイルを作成する
                            , MakeAvs
                            , strInputFilePathWithoutExtension)
                    },
                    {
                        // chapter_exeでavsファイルを読み込み、無音空間のフレームを検出したテキストファイルを出力する
                        "ChapterExe"
                        , new ExternalAppSettings(
                            "ChapterExe"
                            , strInputFilePathWithoutExtension
                            , null
                            , strInputFilePathWithoutExtension)
                    },
                    {
                        // logoframe.exeでavsファイルを読み込み、ロゴが出現している区間のフレームを取得
                        "LogoFrame"
                        , new ExternalAppSettings(
                            "LogoFrame"
                            , strInputFilePathWithoutExtension
                            , null
                            , strInputFilePathWithoutExtension
                            , Path.Combine(
                                Program.CurrentDirectory
                                , XDOCUMENT_CONFIG_LIBRARY.ReadConfig("LogoData", CONFIG_LIBRARY_NODE_PATH)
                                , GetLogoData(file)))
                    },
                    {
                        // join_logo_scp.exeで、chapter_exeとlogoframeが出力したテキストを読み込み、ロゴが出現/消滅した付近のフレームを取得
                        "JoinLogo"
                        , new ExternalAppSettings(
                            "JoinLogo"
                            , strInputFilePathWithoutExtension
                            , AddTrimDataToAVS
                            , strInputFilePathWithoutExtension
                            , strInputFilePathWithoutExtension
                            , Path.Combine(
                                Program.CurrentDirectory
                                , XDOCUMENT_CONFIG_LIBRARY.ReadConfig("JoinLogoConfig", CONFIG_LIBRARY_NODE_PATH)))
                    },
                    {
                        // AviUtlを起動し、2秒待つ(bat内のWaitがうまく作動しないため、起動処理のみ分離)
                        "AviUtl"
                        , new ExternalAppSettings(
                            "AviUtl"
                            , String.Empty
                            , WaitProcess(2)
                            , String.Empty
                            )
                    },
                    {
                        // AviutlでCMカット情報が記載されたavsをもとに動画をmp4へエンコードする
                        "Auc"
                        , new ExternalAppSettings(
                            "Auc"
                            , strInputFilePathWithoutExtension
                            // 処理の一番最後なので、成果物の移動や一時ファイルの移動などを行う
                            , AfterEncode(file)
                            , String.Empty
                            , strInputFilePathWithoutExtension
                            )
                    }
                };

                dicAllEncodeInfo.Add(file, dicSettings);
            }

            #region 外部アプリケーションの処理
            Task taskBefore = Task.Factory.StartNew(new Action(() => { }));

            foreach (KeyValuePair <string, Dictionary <string, ExternalAppSettings> > dicAllSettings in dicAllEncodeInfo)
            {
                taskBefore = taskBefore.ContinueWith(new Action <Task>((task) =>
                {
                    // 録画ディレクトリのTSファイルを作業ディレクトリへ移動する
                    File.Move(PATH_DIR_RECORD + dicAllSettings.Key + ".ts", strInputFilePath);
                }));
                foreach (KeyValuePair <string, ExternalAppSettings> settings in dicAllSettings.Value)
                {
                    taskBefore = TaskExtAppExecute(settings.Value, taskBefore);
                }
            }
            #endregion
        }