Ejemplo n.º 1
0
        private void btnCompile_Click(object sender, EventArgs e)
        {
            if (!tbFilePath.Text.EndsWith(".mp4") &&
                !tbMetaPath.Text.EndsWith(".mxml"))
            {

                MessageBox.Show(this, "请补全信息再试!", "错误",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            MetaDataModel mdm;

            if (CoreData.CommonData.mdm == null)
            {
                MetaXMLReader metaReader = new MetaXMLReader();
                mdm = metaReader.readMetaHeaderFile(tbMetaPath.Text);
            }

            else
            {
                mdm = CoreData.CommonData.mdm;
            }

            if (mdm.posterPath != "")
            {
                mvca = new mp4v2Wrapper.mp4v2CoverArt(mdm.posterPath, tbFilePath.Text);
            }

            mvt = new mp4v2Wrapper.mp4v2Tagging(mdm, tbFilePath.Text);

            //Subtitles
            if (mdm.subtitles.Count != 0)
            {
                foreach (KeyValuePair<String, String> pair in mdm.subtitles)
                {
                    MP4BoxWrapper.MP4BoxTrackModel mtm
                        = new MP4BoxWrapper.MP4BoxTrackModel();

                    mtm.trackName = "Subtitle Track";
                    mtm.trackToAdd = pair.Value;
                    mtm.trackType = MP4BoxWrapper.MP4BoxTrackModel.TrackType.Subtitle;
                    mtm.languageCode = pair.Key;
                    mtm.groupID = 2;
                    mtm.originalVideo = tbFilePath.Text;

                    lIT.Add(new MP4BoxWrapper.ImportTrack(mtm));
                }
            }

            //chapters
            if ( mdm.chaptersFilePath.EndsWith(".txt") || mdm.chaptersFilePath.EndsWith(".ogm") )
            {
                MP4BoxWrapper.MP4BoxTrackModel mtm
                        = new MP4BoxWrapper.MP4BoxTrackModel();

                mtm.trackName = "Chapters";
                mtm.trackToAdd = mdm.chaptersFilePath;
                mtm.trackType = MP4BoxWrapper.MP4BoxTrackModel.TrackType.Chapter;
                mtm.originalVideo = tbFilePath.Text;

                lIT.Add(new MP4BoxWrapper.ImportTrack(mtm));
            }

            gbVideoNMeta.Enabled = false;
            btnCompile.Enabled = false;
            pbCompileProgress.Style = ProgressBarStyle.Marquee;
            pbCompileProgress.MarqueeAnimationSpeed = 100;

            mp4CompileWorker.RunWorkerAsync();
        }
Ejemplo n.º 2
0
        private void btnCompile_Click(object sender, EventArgs e)
        {
            if (!tbFilePath.Text.EndsWith(".mp4") &&
                !tbMetaPath.Text.EndsWith(".mxml"))
            {
                MessageBox.Show(this, "请补全信息再试!", "错误",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            MetaDataModel mdm;

            if (CoreData.CommonData.mdm == null)
            {
                MetaXMLReader metaReader = new MetaXMLReader();
                mdm = metaReader.readMetaHeaderFile(tbMetaPath.Text);
            }

            else
            {
                mdm = CoreData.CommonData.mdm;
            }

            if (mdm.posterPath != "")
            {
                mvca = new mp4v2Wrapper.mp4v2CoverArt(mdm.posterPath, tbFilePath.Text);
            }

            mvt = new mp4v2Wrapper.mp4v2Tagging(mdm, tbFilePath.Text);

            //Subtitles
            if (mdm.subtitles.Count != 0)
            {
                foreach (KeyValuePair <String, String> pair in mdm.subtitles)
                {
                    MP4BoxWrapper.MP4BoxTrackModel mtm
                        = new MP4BoxWrapper.MP4BoxTrackModel();

                    mtm.trackName     = "Subtitle Track";
                    mtm.trackToAdd    = pair.Value;
                    mtm.trackType     = MP4BoxWrapper.MP4BoxTrackModel.TrackType.Subtitle;
                    mtm.languageCode  = pair.Key;
                    mtm.groupID       = 2;
                    mtm.originalVideo = tbFilePath.Text;

                    lIT.Add(new MP4BoxWrapper.ImportTrack(mtm));
                }
            }

            //chapters
            if (mdm.chaptersFilePath.EndsWith(".txt") || mdm.chaptersFilePath.EndsWith(".ogm"))
            {
                MP4BoxWrapper.MP4BoxTrackModel mtm
                    = new MP4BoxWrapper.MP4BoxTrackModel();

                mtm.trackName     = "Chapters";
                mtm.trackToAdd    = mdm.chaptersFilePath;
                mtm.trackType     = MP4BoxWrapper.MP4BoxTrackModel.TrackType.Chapter;
                mtm.originalVideo = tbFilePath.Text;

                lIT.Add(new MP4BoxWrapper.ImportTrack(mtm));
            }

            gbVideoNMeta.Enabled    = false;
            btnCompile.Enabled      = false;
            pbCompileProgress.Style = ProgressBarStyle.Marquee;
            pbCompileProgress.MarqueeAnimationSpeed = 100;

            mp4CompileWorker.RunWorkerAsync();
        }