{"id":2020,"date":"2017-11-06T06:18:41","date_gmt":"2017-11-05T21:18:41","guid":{"rendered":"http:\/\/okamurax.com\/?p=2020"},"modified":"2024-05-03T18:59:59","modified_gmt":"2024-05-03T09:59:59","slug":"c-%e6%8c%87%e5%ae%9a%e7%a7%92%e6%95%b0%e3%81%a7%e3%82%b5%e3%83%a0%e3%83%8d%e3%82%a4%e3%83%ab%e4%bd%9c%e6%88%90-ver2","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2020","title":{"rendered":"C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2461"},"content":{"rendered":"<blockquote class=\"wp-embedded-content\" data-secret=\"W2Kn8Dw8JI\"><p><a href=\"https:\/\/appbay.org\/?p=4379\">C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22+\u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210(FFmpeg)<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22+\u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210(FFmpeg)&#8221; &#8212; \u30c6\u30c3\u30af\u30e1\u30e2\" src=\"https:\/\/appbay.org\/?p=4379&#038;embed=true#?secret=XrMhjTUIm8#?secret=W2Kn8Dw8JI\" data-secret=\"W2Kn8Dw8JI\" width=\"525\" height=\"296\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u4f5c\u3063\u3066\u307f\u305f\u3089\u610f\u5916\u3068\u4f7f\u3048\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u5c11\u3005\u6a5f\u80fd\u8ffd\u52a0\u3002<\/p>\n<p>\u8aad\u307f\u8fbc\u307f\u306e\u51e6\u7406\u3092\u975e\u540c\u671f\u306b\u3057\u3066\u56fa\u307e\u3089\u306a\u3044\u3088\u3046\u306b\u3002<br \/>\n\u30bf\u30d6\u306b\u9032\u6357\u3092\u8868\u793a\u3002<br \/>\n\u30bf\u30d6\u306b\u8aad\u307f\u8fbc\u3093\u3060\u30d1\u30b9\u3092\u8a18\u5165\u3002<br \/>\n\u30bf\u30d6\u306e\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u30bf\u30d6\u524a\u9664\u3002<br \/>\n\u30b5\u30e0\u30cd\u30a4\u30eb\u5de6\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u6a19\u6e96\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8d77\u52d5\u3002<br \/>\n\u30b5\u30e0\u30cd\u30a4\u30eb\u53f3\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u8d77\u52d5\u3002<br \/>\n\u691c\u7d22\u6a5f\u80fd\u8ffd\u52a0\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u306e\u89aa\u30d5\u30a9\u30eb\u30c0\u306e\u540d\u524d\u3092\u8a18\u5165\u3002<br \/>\n\u6307\u5b9a\u79d2\u6570\u3088\u308a\u77ed\u3044\u30d5\u30a1\u30a4\u30eb\u3082\u30a8\u30e9\u30fc\u3067\u306f\u306a\u304f\u900f\u660e\u306e\u753b\u50cf\u3068\u3057\u305f\u3002<\/p>\n<p>\u30b5\u30e0\u30cd\u30a4\u30eb\u306e\u53d6\u5f97\u306bffmpeg\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u5834\u6240\u306bffmpeg.exe\u304c\u5fc5\u8981\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nnamespace themenail\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            tabControl1.Font = new Font(\"Meiryo UI\", 11);\r\n            tabControl1.MouseDoubleClick += new MouseEventHandler(tpDbClick);\r\n\r\n            this.FormClosed += new FormClosedEventHandler((object sender, FormClosedEventArgs e) =&gt; {\r\n\r\n                foreach (System.Diagnostics.Process p in ProcessList)\r\n                {\r\n                    try\r\n                    {\r\n                        if (!p.HasExited) p.Kill();\r\n                    }\r\n                    catch { }\r\n                }\r\n            });\r\n        }\r\n\r\n        private List&lt;System.Diagnostics.Process&gt; ProcessList = new List&lt;System.Diagnostics.Process&gt;();\r\n\r\n        private async void BtnClick()\r\n        {\r\n            List&lt;string&gt; path = new List&lt;string&gt;();\r\n\r\n            foreach (string f in System.IO.Directory.GetFiles(textBox2.Text))\r\n            {\r\n                path.Add(f);\r\n            }\r\n            foreach (string d in System.IO.Directory.GetDirectories(textBox2.Text,\"*\",System.IO.SearchOption.AllDirectories))\r\n            {\r\n                foreach (string f in System.IO.Directory.GetFiles(d,\"*.mp4\"))\r\n                {\r\n                    path.Add(f);\r\n                }\r\n            }\r\n\r\n            string ss = textBox1.Text;\r\n            string[] files = path.ToArray();\r\n\r\n            TabPage tp = new TabPage();\r\n            tp.Text = \"\u958b\u59cb\u4e2d...\";\r\n\r\n            tabControl1.Controls.Add(tp);\r\n            tabControl1.SelectedTab = tp;\r\n\r\n            Label lb = new Label();\r\n            lb.Font = new Font(\"Meiryo UI\", 11);\r\n            lb.Text = textBox2.Text;\r\n\r\n            ImageList il = new ImageList();\r\n            il.ImageSize = new Size(255, 255);\r\n            il.ColorDepth = ColorDepth.Depth24Bit;\r\n\r\n            ListView lv = new ListView();\r\n\r\n            System.Diagnostics.Process p = new System.Diagnostics.Process();\r\n            ProcessList.Add(p);\r\n\r\n            await Task.Run(() =&gt;\r\n            {\r\n                for (int i = 0; i &lt; files.Length; i++)\r\n                {\r\n                    try\r\n                    {\r\n                        Invoke((Action)(() =&gt;\r\n                        {\r\n                            tp.Text = i.ToString() + \"\/\" + files.Length.ToString();\r\n                        }));\r\n                    }\r\n                    catch (System.ObjectDisposedException)\r\n                    {\r\n                        return;\r\n                    }\r\n\r\n                    System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo(\r\n                    Application.StartupPath + @\"\\ffmpeg.exe\", \"-ss \" + ss + \" -i \\\"\" + files[i] + \"\\\" -vframes 1 -f image2 pipe:1\");\r\n                    ps.RedirectStandardOutput = true;\r\n                    ps.CreateNoWindow = true;\r\n                    ps.UseShellExecute = false;\r\n\r\n                    p.StartInfo = ps;\r\n\r\n                    try\r\n                    {\r\n                        p.Start(); \r\n                    }\r\n                    catch (System.ComponentModel.Win32Exception e)\r\n                    {\r\n                        MessageBox.Show(e.Message);\r\n                        return;\r\n                    }\r\n\r\n                    Image img;\r\n\r\n                    try\r\n                    {\r\n                        img = Image.FromStream(p.StandardOutput.BaseStream);\r\n                    }\r\n                    catch (System.ArgumentException)\r\n                    {\r\n                        img = new Bitmap(255, 255);\r\n                    }\r\n\r\n                    Image theme = img.GetThumbnailImage(255, 255, null, IntPtr.Zero);\r\n                    il.Images.Add(theme);\r\n                    string parent = System.IO.Directory.GetParent(files[i]).Name;\r\n                    ListViewItem lvi = lv.Items.Add(\"(\" + parent + \")\" + System.IO.Path.GetFileName(files[i]), i);\r\n                    lvi.SubItems.Add(files[i]);\r\n                }\r\n            });\r\n\r\n            lv.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;\r\n            lv.Size = new Size(tp.Size.Width - 2, tp.Height - 1 - 25);\r\n            lv.Top = 25;\r\n            lv.LargeImageList = il;\r\n            lv.MouseDoubleClick += new MouseEventHandler(lvDbClick);\r\n\r\n            lb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;\r\n            lb.Top = 2;\r\n            lb.Left = 2;\r\n            lb.Width = lv.Width;\r\n\r\n            tp.Controls.Add(lb);\r\n            tp.Controls.Add(lv);\r\n            tp.Text = \"\u5b8c\u4e86\";\r\n        }\r\n\r\n        private void lvDbClick(object sender, MouseEventArgs e)\r\n        {\r\n            string path = ((ListView)sender).SelectedItems[0].SubItems[1].Text;\r\n            string file = ((ListView)sender).SelectedItems[0].Text;\r\n\r\n            if (!System.IO.File.Exists(path)) return;\r\n\r\n            if (e.Button == MouseButtons.Right)\r\n            {\r\n                System.Diagnostics.Process p = new System.Diagnostics.Process();\r\n                p.StartInfo.FileName = \"explorer\";\r\n                p.StartInfo.Arguments = \"\/select,\" + path;\r\n                p.Start();\r\n            }\r\n            if (e.Button == MouseButtons.Left)\r\n            {\r\n                System.Diagnostics.Process p = System.Diagnostics.Process.Start(path);\r\n            }\r\n        }\r\n\r\n        private void tpDbClick(object sender, MouseEventArgs e)\r\n        {\r\n            tabControl1.TabPages.Remove(((TabControl)sender).SelectedTab);\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (textBox1.Text == \"\" || textBox2.Text == \"\") return;\r\n            if (!System.IO.Directory.Exists(textBox2.Text)) return;\r\n            BtnClick();\r\n        }\r\n\r\n        List&lt;ListView&gt; TempListView = new List&lt;ListView&gt;();\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            if (tabControl1.TabCount == 0) return;\r\n            if (tabControl1.SelectedTab.Text != \"\u5b8c\u4e86\") return;\r\n\r\n            if (tabControl1.SelectedTab.Name == \"\")\r\n            {\r\n                string guid = System.Guid.NewGuid().ToString();\r\n                tabControl1.SelectedTab.Name = guid;\r\n\r\n                ListView lv = new ListView();\r\n                lv.Name = guid;\r\n\r\n                int r = 0;\r\n                foreach (ListViewItem i in ((ListView)tabControl1.SelectedTab.Controls[1]).Items)\r\n                {\r\n                    lv.Items.Add(\"\");\r\n                    lv.Items[r] = (ListViewItem)i.Clone();\r\n                    r++;\r\n                }\r\n                TempListView.Add(lv);\r\n            }\r\n\r\n            if (tabControl1.SelectedTab.Name != \"\")\r\n            {\r\n                foreach (ListView i in TempListView)\r\n                {\r\n                    if (i.Name == tabControl1.SelectedTab.Name)\r\n                    {\r\n                        ((ListView)tabControl1.SelectedTab.Controls[1]).Items.Clear();\r\n\r\n                        int r = 0;\r\n                        foreach (ListViewItem k in i.Items)\r\n                        {\r\n                            ((ListView)tabControl1.SelectedTab.Controls[1]).Items.Add(\"\");\r\n                            ((ListView)tabControl1.SelectedTab.Controls[1]).Items[r] = (ListViewItem)k.Clone();\r\n                            r++;\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n\r\n            if (textBox3.Text != \"\")\r\n            {\r\n                foreach (ListViewItem i in ((ListView)tabControl1.SelectedTab.Controls[1]).Items)\r\n                {\r\n                    if (i.Text.IndexOf(textBox3.Text,StringComparison.OrdinalIgnoreCase) &lt;= 0) i.Remove();\r\n                }\r\n            }\r\n        }\r\n\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            foreach (TabPage t in tabControl1.TabPages)\r\n            {\r\n                tabControl1.SelectedTab = t;\r\n                button2.PerformClick();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22+\u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210(FFmpeg) \u4f5c\u3063\u3066\u307f\u305f\u3089\u610f\u5916\u3068\u4f7f\u3048\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u5c11\u3005\u6a5f\u80fd\u8ffd\u52a0\u3002 \u8aad\u307f\u8fbc\u307f\u306e\u51e6\u7406\u3092\u975e\u540c\u671f\u306b\u3057\u3066\u56fa\u307e\u3089\u306a\u3044\u3088\u3046\u306b\u3002 \u30bf\u30d6\u306b\u9032\u6357\u3092\u8868\u793a\u3002 \u30bf\u30d6\u306b\u8aad\u307f\u8fbc\u3093\u3060\u30d1\u30b9\u3092\u8a18\u5165\u3002 \u30bf\u30d6\u306e &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2020\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2461&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-2020","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2020"}],"version-history":[{"count":17,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2020\/revisions"}],"predecessor-version":[{"id":6301,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2020\/revisions\/6301"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}