{"id":2013,"date":"2017-11-03T23:16:07","date_gmt":"2017-11-03T14:16:07","guid":{"rendered":"http:\/\/okamurax.com\/?p=2013"},"modified":"2024-05-03T18:59:34","modified_gmt":"2024-05-03T09:59:34","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","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2013","title":{"rendered":"C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2460"},"content":{"rendered":"<p>\u7279\u5b9a\u30d5\u30a9\u30eb\u30c0\u4ee5\u4e0b\u306emp4\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u6307\u5b9a\u79d2\u6570\u3067\u53d6\u5f97\u3057\u305f\u304f\u306a\u3063\u305f\u3002\u53d6\u5f97\u3092\u3059\u308b\u305f\u3073\u306b\u65b0\u3057\u3044\u30bf\u30d6\u30da\u30fc\u30b8\u3092\u8ffd\u52a0\u3059\u308b\u3002\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001explorer\u3067\u958b\u304f\u3002<\/p>\n<p>\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            toolStripProgressBar1.Visible  = false;\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\r\n            toolStripProgressBar1.Visible = true;\r\n\r\n            string path = textBox2.Text;\r\n            string[] files;\r\n\r\n            TabPage tp = new TabPage();\r\n            ListView lv = new ListView();\r\n            ImageList il = new ImageList();\r\n\r\n            il.ImageSize = new Size(255, 255);\r\n            il.ColorDepth = ColorDepth.Depth32Bit;\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-3);\r\n            lv.Top = 2;\r\n            lv.LargeImageList = il;\r\n            lv.MouseDoubleClick += new MouseEventHandler(DbClick);\r\n\r\n            tp.Controls.Add(lv);\r\n            tabControl1.Controls.Add(tp);\r\n            tabControl1.SelectedTab = tp;\r\n\r\n            try\r\n            {\r\n                files = System.IO.Directory.GetFiles(path, \"*.mp4\",System.IO.SearchOption.AllDirectories);\r\n                toolStripProgressBar1.Minimum = 0;\r\n                toolStripProgressBar1.Maximum = files.Length;\r\n\r\n                for (int i = 0; i &lt; files.Length; i++)\r\n                {\r\n                    Application.DoEvents();\r\n                    toolStripProgressBar1.Value = i;\r\n\r\n                    System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo(\r\n                        Application.StartupPath + @\"\\ffmpeg.exe\", \"-ss \" + textBox1.Text + \" -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                    System.Diagnostics.Process p = new System.Diagnostics.Process();\r\n                    p.StartInfo = ps;\r\n                    p.Start();\r\n\r\n                    Image img = Image.FromStream(p.StandardOutput.BaseStream);\r\n                    Image theme = img.GetThumbnailImage(255, 255, null, IntPtr.Zero);\r\n\r\n                    il.Images.Add(theme);\r\n                    lv.Items.Add(files[i], i);\r\n                }\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                MessageBox.Show(ex.Message);\r\n            }\r\n\r\n            toolStripProgressBar1.Visible = false;\r\n\r\n            MessageBox.Show(\"\u5b8c\u4e86\");\r\n        }\r\n\r\n        private void DbClick(object sender, MouseEventArgs e)\r\n        {\r\n            string path =  ((ListView)sender).SelectedItems[0].Text;\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    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7279\u5b9a\u30d5\u30a9\u30eb\u30c0\u4ee5\u4e0b\u306emp4\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u6307\u5b9a\u79d2\u6570\u3067\u53d6\u5f97\u3057\u305f\u304f\u306a\u3063\u305f\u3002\u53d6\u5f97\u3092\u3059\u308b\u305f\u3073\u306b\u65b0\u3057\u3044\u30bf\u30d6\u30da\u30fc\u30b8\u3092\u8ffd\u52a0\u3059\u308b\u3002\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001explorer\u3067\u958b\u304f\u3002 \u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u5834\u6240\u306bffmpeg.exe\u304c\u5fc5\u8981\u3002 usin &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2013\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2460&#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-2013","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\/2013","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=2013"}],"version-history":[{"count":7,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2013\/revisions"}],"predecessor-version":[{"id":6300,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2013\/revisions\/6300"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}