{"id":4379,"date":"2021-05-10T03:49:49","date_gmt":"2021-05-09T18:49:49","guid":{"rendered":"https:\/\/okamurax.com\/?p=4379"},"modified":"2024-11-19T10:57:24","modified_gmt":"2024-11-19T01:57:24","slug":"c-%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e6%a4%9c%e7%b4%a2%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=4379","title":{"rendered":"C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22+\u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210(FFmpeg)"},"content":{"rendered":"<p>\u4ee5\u524d\uff64fenrir(B@r09u3 Style Op.2)\u306e\u4ee3\u66ff\u3068\u3057\u3066\u81ea\u5206\u7528\u306b\u4f5c\u6210\u3057\u305f\u691c\u7d22\u30bd\u30d5\u30c8\u306b\u30b5\u30e0\u30cd\u30a4\u30eb\u6a5f\u80fd\u3092\u8ffd\u52a0\uff61<\/p>\n<p>\u203b\u8ffd\u8a18(\u30d5\u30a1\u30a4\u30eb\u6dfb\u4ed8)<\/p>\n<p><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/appbay.org\/wp-content\/uploads\/2021\/05\/Release.zip\">Release20241118<\/a><\/span><\/p>\n<p>\u4f7f\u3044\u65b9<br \/>\n\uff65\u89e3\u51cd\u5f8c\uff64<span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.gyan.dev\/ffmpeg\/builds\/\">ffmpeg.exe<\/a><\/span>\u3092\u30d5\u30a9\u30eb\u30c0\u306e\u4e2d\u306b\u4fdd\u5b58\uff61(\u30b5\u30e0\u30cd\u30a4\u30eb\u8868\u793a\u3057\u306a\u3044\u306a\u3089\u4e0d\u8981)<br \/>\n\uff65scan.txt\u306e\u4e2d\u306b\u691c\u7d22\u3057\u305f\u3044\u30d1\u30b9\u3092\u8a18\u5165\uff61(\u8907\u6570\u884c\u53ef)<br \/>\n\uff65CreateIndex.exe\u3092\u5b9f\u884c\uff61<br \/>\n\uff65FileSearch.exe\u3092\u5b9f\u884c\uff61<br \/>\n\uff65\u8907\u6570\u691c\u7d22\u306f\u30d0\u30fc\u30c6\u30a3\u30ab\u30eb\u30d0\u30fc(|)\u3067\u533a\u5207\u308b\uff61AND\u691c\u7d22\uff61<br \/>\n\uff65\u691c\u7d22\u7d50\u679c\u306e\u30ea\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u4e0a\uff1a\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u76f4\u63a5\u958b\u304f\uff61Ctrl+\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f\uff61<br \/>\n\uff65\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u4e0a\uff1aCtrl+Enter\u3067\uff64\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u8868\u793a\uff61(\u6570\u5b57\u5165\u529b\u306e\u30c0\u30a4\u30a2\u30ed\u30b0\u306f\u4f55\u79d2\u76ee\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u306b\u3059\u308b\u304b\u6307\u5b9a)<br \/>\n\uff65\u30b5\u30e0\u30cd\u30a4\u30eb\u4e0a\uff1a\u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u76f4\u63a5\u958b\u304f\uff61Ctrl+\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f\uff61<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"FC0rtOByAA\"><p><a href=\"https:\/\/appbay.org\/?p=4139\">C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22(\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30bf\u30eb\u30b5\u30fc\u30c1)<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22(\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30bf\u30eb\u30b5\u30fc\u30c1)&#8221; &#8212; \u30c6\u30c3\u30af\u30e1\u30e2\" src=\"https:\/\/appbay.org\/?p=4139&#038;embed=true#?secret=3bGD9R8kGD#?secret=FC0rtOByAA\" data-secret=\"FC0rtOByAA\" width=\"525\" height=\"296\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"TAlKmD92fd\"><p><a href=\"https:\/\/appbay.org\/?p=2020\">C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2461<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;C# \u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210\u2461&#8221; &#8212; \u30c6\u30c3\u30af\u30e1\u30e2\" src=\"https:\/\/appbay.org\/?p=2020&#038;embed=true#?secret=HDzgVE7Vvb#?secret=TAlKmD92fd\" data-secret=\"TAlKmD92fd\" width=\"525\" height=\"296\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u6307\u5b9a\u30d5\u30a9\u30eb\u30c0\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3057\u3066\u304a\u304d\u3001\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30bf\u30eb\u30b5\u30fc\u30c1\u306e\u4e00\u89a7\u3092\u3082\u3068\u306bFFmpeg\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>CreateThumbnail1()\u306fUI\u306e\u90e8\u5206\u3060\u3051\u56fa\u307e\u3089\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u304c\u3001\u30b5\u30e0\u30cd\u30a4\u30eb\u306e\u4f5c\u6210\u306f\u4e26\u5217\u5316\u3057\u3066\u3044\u306a\u3044\u3002CreateThumbnail2()\u306f\u30b5\u30e0\u30cd\u30a4\u30eb\u306e\u4f5c\u6210\u307e\u3067\u4e26\u5217\u5316\u3057\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.Data;\r\nusing System.Diagnostics;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Windows.Forms;\r\nusing System.Xml.Serialization;\r\n\r\nnamespace FileSearch\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        string RemoteIndexPath = Application.StartupPath + @\"\\remote_index_path.txt\";\r\n        string IndexPath = Application.StartupPath + @\"\\index.dat\";\r\n\r\n        List&lt;string&gt; RawItems = new List&lt;string&gt;();\r\n        System.Collections.Concurrent.ConcurrentBag&lt;string&gt; FilterItems = new System.Collections.Concurrent.ConcurrentBag&lt;string&gt;();\r\n\r\n        List&lt;SubForm&gt; Children = new List&lt;SubForm&gt;();\r\n\r\n        int VisibleCount = 1000;\r\n        int RawItemCount = 0;\r\n        string WriteTime = \"\";\r\n        string Needle = \"\";\r\n\r\n        object LockObject = new object();\r\n        bool IsExit = true;\r\n\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            if (!IndexLoad()) return;\r\n\r\n            LoadPosition();\r\n\r\n            var delayExecute = new DelayExecute();\r\n            delayExecute.Execute += (s, e) =&gt; SetupDatasource();\r\n\r\n            textBox1.TextChanged += (s, e) =&gt;\r\n            {\r\n                lock (LockObject)\r\n                {\r\n                    IsExit = false;\r\n                }\r\n                Needle = textBox1.Text;\r\n                delayExecute.ReserveExecute();\r\n            };\r\n\r\n            textBox1.KeyDown += (s, e) =&gt; OpenSubForm(s, e);\r\n            listBox1.MouseDoubleClick += (s, e) =&gt; OpenFile(s, e);\r\n            \r\n            this.SizeChanged += (s, e) =&gt;\r\n            {\r\n                if (this.WindowState == FormWindowState.Minimized || this.WindowState == FormWindowState.Maximized) return;\r\n                SavePosition();\r\n            };\r\n\r\n            this.FormClosing += (s, e) =&gt;\r\n            {\r\n                if (Children.Count &gt; 0)\r\n                {\r\n                    MessageBox.Show(\"\u30d5\u30a9\u30fc\u30e0\u3092\u5168\u3066\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                    e.Cancel = true;\r\n                    return;\r\n                }\r\n\r\n                lock (LockObject)\r\n                {\r\n                    if (!IsExit) e.Cancel = true;\r\n                }\r\n            };\r\n        }\r\n\r\n        private void OpenSubForm(object sender, KeyEventArgs e)\r\n        {\r\n            lock (LockObject)\r\n            {\r\n                if (!IsExit) return;\r\n            }\r\n\r\n            if (FilterItems.Count == 0) return;\r\n\r\n            if (e.Control &amp;&amp; e.KeyCode == Keys.Enter)\r\n            {\r\n                string startTime = \"0\";\r\n\r\n                var input = new InputBox();\r\n                input.StartPosition = FormStartPosition.Manual;\r\n                input.Left = DesktopLocation.X + 10;\r\n                input.Top = DesktopLocation.Y + 10;\r\n                input.ShowDialog();\r\n                \r\n                if (input.IsClick)\r\n                {\r\n                    int.TryParse(input.Value, out int result);\r\n                    startTime = result.ToString();\r\n                }\r\n\r\n                var f = new SubForm(textBox1.Text, new List&lt;string&gt;(FilterItems), startTime);\r\n\r\n                string handle = Guid.NewGuid().ToString(\"N\");\r\n                f.Id = handle;\r\n\r\n                f.FormClosed += (ss, ee) =&gt;\r\n                {\r\n                    Children = new List&lt;SubForm&gt;(Children.Where(x =&gt; x.Id != handle));\r\n                };\r\n\r\n                Children.Add(f);\r\n                f.Show();\r\n            }\r\n        }\r\n\r\n        private bool IndexLoad()\r\n        {\r\n            string remoteIndexPath = \"\";\r\n            if (File.Exists(RemoteIndexPath)) \r\n            {\r\n                remoteIndexPath = File.ReadAllText(RemoteIndexPath);\r\n            }\r\n\r\n            if (!File.Exists(IndexPath) &amp;&amp; !File.Exists(remoteIndexPath)) \/\/ \u30ed\u30fc\u30ab\u30eb\u3001\u30ea\u30e2\u30fc\u30c8\u306b\u306a\u3044\u5834\u5408\r\n            {\r\n                MessageBox.Show(\"\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\");\r\n                return false;\r\n            }\r\n            else if (File.Exists(IndexPath) &amp;&amp; !File.Exists(remoteIndexPath)) \/\/ \u30ed\u30fc\u30ab\u30eb\u306b\u3042\u3063\u3066\u3001\u30ea\u30e2\u30fc\u30c8\u306b\u306a\u3044\u5834\u5408\r\n            {\r\n                RawItems = File.ReadAllLines(IndexPath).ToList();\r\n                RawItemCount = RawItems.Count();\r\n                WriteTime = File.GetLastWriteTime(IndexPath).ToString(\"yyyy\/MM\/dd HH:mm:ss\");\r\n            }\r\n            else if (!File.Exists(IndexPath) &amp;&amp; File.Exists(remoteIndexPath)) \/\/ \u30ed\u30fc\u30ab\u30eb\u306b\u306a\u304f\u3066\u3001\u30ea\u30e2\u30fc\u30c8\u306b\u3042\u308b\u5834\u5408\r\n            {\r\n                File.Copy(remoteIndexPath, IndexPath);\r\n                RawItems = File.ReadAllLines(IndexPath).ToList();\r\n                RawItemCount = RawItems.Count();\r\n                WriteTime = File.GetLastWriteTime(IndexPath).ToString(\"yyyy\/MM\/dd HH:mm:ss\");\r\n            }\r\n            else if (File.Exists(IndexPath) &amp;&amp; File.Exists(remoteIndexPath)) \/\/ \u30ed\u30fc\u30ab\u30eb\u3001\u30ea\u30e2\u30fc\u30c8\u306b\u3042\u308b\u5834\u5408\r\n            {\r\n                if (File.GetLastWriteTime(IndexPath) &lt; File.GetLastWriteTime(remoteIndexPath)) \/\/ \u30ea\u30e2\u30fc\u30c8\u306e\u65b9\u304c\u6700\u65b0\u306e\u5834\u5408\r\n                { \r\n                    if (DialogResult.Yes == MessageBox.Show(\"\u6700\u65b0\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u66f4\u65b0\u3057\u307e\u3059\u304b\uff1f\",\"\", MessageBoxButtons.YesNo))\r\n                    {\r\n                        File.Copy(remoteIndexPath, IndexPath, true);\r\n                    }\r\n                    RawItems = File.ReadAllLines(IndexPath).ToList();\r\n                    RawItemCount = RawItems.Count();\r\n                    WriteTime = File.GetLastWriteTime(IndexPath).ToString(\"yyyy\/MM\/dd HH:mm:ss\");\r\n                }\r\n                else \/\/ \u30ed\u30fc\u30ab\u30eb\u306e\u65b9\u304c\u6700\u65b0\u306e\u5834\u5408\r\n                {\r\n                    RawItems = File.ReadAllLines(IndexPath).ToList();\r\n                    RawItemCount = RawItems.Count();\r\n                    WriteTime = File.GetLastWriteTime(IndexPath).ToString(\"yyyy\/MM\/dd HH:mm:ss\");\r\n                }\r\n            }\r\n            return true;\r\n        }\r\n\r\n        private void SetupDatasource()\r\n        {\r\n            var stopwatch = new Stopwatch();\r\n            stopwatch.Start();\r\n\r\n            IEnumerable&lt;string&gt; items = new List&lt;string&gt;();\r\n            \r\n            if (Needle == \"\")\r\n            {\r\n                items = RawItems.Take(VisibleCount);\r\n            }\r\n            else\r\n            {\r\n                List&lt;string&gt; tmpList = new List&lt;string&gt;(RawItems);\r\n\r\n                foreach (string tmpString in Needle.Split('|'))\r\n                {\r\n                    tmpList = tmpList.AsParallel().Where(x =&gt; x.ToLower().Contains(tmpString.ToLower())).ToList();\r\n                }\r\n                items = tmpList.Take(VisibleCount);\r\n            }\r\n\r\n            var itemClassList = new System.Collections.Concurrent.ConcurrentBag&lt;ItemClass&gt;();\r\n            FilterItems = new System.Collections.Concurrent.ConcurrentBag&lt;string&gt;();\r\n\r\n            System.Threading.Tasks.Parallel.ForEach(items, item =&gt;\r\n            {\r\n                itemClassList.Add(new ItemClass()\r\n                {\r\n                    DisplayItemPath = Path.GetFileName(item) + \" . . . \u25a0\" + Path.GetDirectoryName(item),\r\n                    ItemPath = item\r\n                });\r\n                FilterItems.Add(item);\r\n            });\r\n\r\n            stopwatch.Stop();\r\n\r\n            Invoke(new Action(() =&gt; {\r\n                listBox1.DataSource = itemClassList.ToList();\r\n                listBox1.DisplayMember = \"DisplayItemPath\";\r\n                Text = items.Count() + \"\/\" + RawItemCount + \"\u4ef6\u8868\u793a (\" + stopwatch.ElapsedMilliseconds.ToString() + \"ms)\uff1a\" + WriteTime + \"\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\";\r\n            }));\r\n\r\n            lock (LockObject)\r\n            {\r\n                IsExit = true;\r\n            }\r\n        }\r\n\r\n        private void OpenFile(object sender, MouseEventArgs e)\r\n        {\r\n            if (listBox1.SelectedItem == null) return;\r\n\r\n            var itemPath = ((ItemClass)listBox1.SelectedItem).ItemPath;\r\n\r\n            if (!File.Exists(itemPath))\r\n            {\r\n                MessageBox.Show(\"\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\");\r\n                return;\r\n            } \r\n\r\n            if (ModifierKeys == Keys.Control)\r\n            {\r\n                var info = new ProcessStartInfo(\"explorer.exe\");\r\n                info.Arguments = $\"\/select, \\\"{itemPath}\\\"\";\r\n                Process.Start(info);\r\n            }\r\n            else\r\n            {\r\n                Process.Start(itemPath);\r\n            }\r\n        }\r\n\r\n        private void LoadPosition()\r\n        {\r\n            if (!File.Exists(Application.StartupPath + @\"\\dat.xml\")) return;\r\n\r\n            this.StartPosition = FormStartPosition.Manual;\r\n\r\n            XmlSerializer xs = new XmlSerializer(typeof(List&lt;int&gt;));\r\n            using (StreamReader sr = new StreamReader(Application.StartupPath + @\"\\dat.xml\", Encoding.UTF8))\r\n            {\r\n                try\r\n                {\r\n                    List&lt;int&gt; items = (List&lt;int&gt;)xs.Deserialize(sr);\r\n                    \r\n                    if (0 &gt; (int)items[2])\r\n                    {\r\n                        this.StartPosition = FormStartPosition.WindowsDefaultLocation;\r\n                        return;\r\n                    }\r\n\r\n                    this.Width = (int)items[0];\r\n                    this.Height = (int)items[1];\r\n                    this.Top = (int)items[2];\r\n                    this.Left = (int)items[3];\r\n                }\r\n                catch\r\n                {\r\n                    this.StartPosition = FormStartPosition.WindowsDefaultLocation;\r\n                }\r\n            }\r\n        }\r\n\r\n        private void SavePosition()\r\n        {\r\n            if (this.WindowState == FormWindowState.Maximized) return;\r\n\r\n            XmlSerializer xs = new XmlSerializer(typeof(List&lt;int&gt;));\r\n            using (StreamWriter sw = new StreamWriter(Application.StartupPath + @\"\\dat.xml\", false, Encoding.UTF8))\r\n            {\r\n                List&lt;int&gt; items = new List&lt;int&gt;();\r\n\r\n                items.Add(this.Width);\r\n                items.Add(this.Height);\r\n                items.Add(this.Top);\r\n                items.Add(this.Left);\r\n\r\n                xs.Serialize(sw, items);\r\n            }\r\n        }\r\n    }\r\n\r\n    struct ItemClass\r\n    {\r\n        public string DisplayItemPath { set; get; }\r\n        public string ItemPath { set; get; }\r\n    }\r\n\r\n    class DelayExecute\r\n    {\r\n        public event EventHandler Execute; \/\/ SetupDatasource()\u3092\u767b\u9332\r\n        private int DelayTime = 500;\r\n\r\n        System.Threading.Timer Timer;\r\n\r\n        public DelayExecute()\r\n        {\r\n            Timer = new System.Threading.Timer(x =&gt; {\r\n                Execute(this, EventArgs.Empty);\r\n            });\r\n        }\r\n\r\n        public void ReserveExecute() \/\/ TextChange\u3067\u767a\u706b\r\n        {\r\n            Timer.Change(DelayTime, Timeout.Infinite); \/\/ Timeout.Infinite\u306f\u4e00\u5ea6\u3060\u3051\u547c\u3076\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.Diagnostics;\r\nusing System.Drawing;\r\nusing System.IO;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\nusing System.Linq;\r\n\r\nnamespace FileSearch\r\n{\r\n    public partial class SubForm : Form\r\n    {\r\n        public string Id { set; get; }\r\n\r\n        object LockObject = new object();\r\n        bool IsExit = false;\r\n\r\n        public SubForm(string needle, List&lt;string&gt; filterItems, string startTime)\r\n        {\r\n            InitializeComponent();\r\n\r\n            var tokenSource = new CancellationTokenSource();\r\n            var token = tokenSource.Token;\r\n\r\n            listView1.MultiSelect = false;\r\n            \r\n            listView1.MouseDoubleClick += (s, e) =&gt;\r\n            {\r\n                string itemPath = listView1.SelectedItems[0].SubItems[1].Text;\r\n\r\n                if (ModifierKeys == Keys.Control)\r\n                {\r\n                    var info = new ProcessStartInfo(\"explorer.exe\");\r\n                    info.Arguments = $\"\/select, \\\"{itemPath}\\\"\";\r\n                    Process.Start(info);\r\n                }\r\n                else\r\n                {\r\n                    Process.Start(itemPath);\r\n                }\r\n            };\r\n\r\n            this.FormClosing += (s, e) =&gt;\r\n            {\r\n                lock (LockObject)\r\n                {\r\n                    if (!IsExit)\r\n                    {\r\n                        tokenSource.Cancel();\r\n                        e.Cancel = true;\r\n                    }\r\n                }\r\n            };\r\n            CreateThumbnail2(needle, filterItems, startTime, token);\r\n        }\r\n\r\n        private async void CreateThumbnail2(string needle, List&lt;string&gt; filterItems, string startTime, CancellationToken token)\r\n        {\r\n            ImageList il = new ImageList();\r\n            il.ImageSize = new Size(200, 200);\r\n            il.ColorDepth = ColorDepth.Depth32Bit;\r\n            listView1.LargeImageList = il;\r\n\r\n            var listItems = new System.Collections.Concurrent.ConcurrentBag&lt;ListViewItem&gt;();\r\n\r\n            var tasks = new List&lt;Task&gt;();\r\n\r\n            foreach (string f in filterItems)\r\n            {\r\n                if (!File.Exists(f)) continue;\r\n                if (Path.GetExtension(f) != \".mp4\" &amp;&amp; Path.GetExtension(f) != \".mkv\" &amp;&amp; Path.GetExtension(f) != \".flv\") continue;\r\n\r\n                var t = Task.Run(() =&gt;\r\n                {\r\n                    if (token.IsCancellationRequested) return;\r\n                    while (!IsHandleCreated) { }\r\n\r\n                    int itemCount = 0;\r\n\r\n                    string option = \" -ss \" + startTime + \" -i \\\"\" + f + \"\\\" -vframes 1 -f image2 pipe:1\";\r\n                    ProcessStartInfo ps = new ProcessStartInfo(Application.StartupPath + @\"\\ffmpeg.exe\", option);\r\n                    ps.RedirectStandardOutput = true;\r\n                    ps.CreateNoWindow = true;\r\n                    ps.UseShellExecute = false;\r\n                    \r\n                    using (Process p = new Process())\r\n                    {\r\n                        try\r\n                        {\r\n                            p.StartInfo = ps;\r\n                            if (!p.Start()) throw new Exception();\r\n\r\n                            using (Image img = Image.FromStream(Stream.Synchronized(p.StandardOutput.BaseStream)))\r\n                            {\r\n                                Image thumb = img.GetThumbnailImage(200, 200, null, IntPtr.Zero);\r\n                                Invoke(new Action(() =&gt;\r\n                                {\r\n                                    il.Images.Add(thumb);\r\n                                    itemCount = il.Images.Count;\r\n                                    \r\n                                }));\r\n                            }\r\n                        }\r\n                        catch (Exception)\r\n                        {\r\n                            Image img = new Bitmap(200, 200);\r\n                            Invoke(new Action(() =&gt;\r\n                            {\r\n                                il.Images.Add(img);\r\n                                itemCount = il.Images.Count;\r\n                            }));\r\n                        }\r\n                    }\r\n\r\n                    string fileName = FileNameComp(Path.GetFileName(f), FileSizeUnit(new FileInfo(f).Length));\r\n\r\n                    var item = new ListViewItem(fileName, itemCount-1);\r\n                    item.SubItems.Add(f);\r\n                    listItems.Add(item);\r\n\r\n                    Invoke((Action)(() =&gt;\r\n                    {\r\n                        Text = \"\u96c6\u8a08 (\" + itemCount.ToString() + \"\u4ef6) : \" + startTime +  \"\u79d2 : \" + needle;\r\n                    }));\r\n\r\n                }, token);\r\n\r\n                tasks.Add(t);\r\n            }\r\n\r\n            try\r\n            {\r\n                await Task.WhenAll(tasks.ToArray());\r\n            }\r\n            catch { }\r\n\r\n            listView1.Items.AddRange(listItems.ToArray());\r\n            Text = \"\u5b8c\u4e86 (\" + il.Images.Count.ToString() + \"\u4ef6) : \" + startTime + \"\u79d2 : \"+ needle;\r\n\r\n            lock (LockObject)\r\n            {\r\n                IsExit = true;\r\n            }\r\n        }\r\n\r\n        private async void CreateThumbnail1(string needle, List&lt;string&gt; filterItems, CancellationToken token)\r\n        {\r\n            ImageList il = new ImageList();\r\n            il.ImageSize = new Size(200, 200);\r\n            il.ColorDepth = ColorDepth.Depth32Bit;\r\n            listView1.LargeImageList = il;\r\n\r\n            int itemIndex = 0;\r\n\r\n            await Task.Run(() =&gt; {\r\n\r\n                while (!IsHandleCreated) { }\r\n                \r\n                foreach (string f in filterItems)\r\n                {\r\n                    if (token.IsCancellationRequested) break;\r\n                    if (!File.Exists(f)) continue;\r\n                    if (Path.GetExtension(f) != \".mp4\" &amp;&amp; Path.GetExtension(f) != \".mkv\" &amp;&amp; Path.GetExtension(f) != \".flv\") continue;\r\n\r\n                    string ss = \"60\";\r\n                    string option = \" -ss \" + ss + \" -i \\\"\" + f + \"\\\" -vframes 1 -f image2 pipe:1\";\r\n\r\n                    ProcessStartInfo ps = new ProcessStartInfo(Application.StartupPath + @\"\\ffmpeg.exe\", option);\r\n                    ps.RedirectStandardOutput = true;\r\n                    ps.CreateNoWindow = true;\r\n                    ps.UseShellExecute = false;\r\n\r\n                    using (Process p = new Process())\r\n                    {\r\n                        try\r\n                        {\r\n                            p.StartInfo = ps;\r\n                            if (!p.Start()) throw new Exception();\r\n\r\n                            using (Image img = Image.FromStream(p.StandardOutput.BaseStream))\r\n                            {\r\n                                Image thumb = img.GetThumbnailImage(200, 200, null, IntPtr.Zero);\r\n                                Invoke(new Action(() =&gt; {\r\n                                    il.Images.Add(thumb);\r\n                                }));\r\n                            }\r\n                        }\r\n                        catch (Exception)\r\n                        {\r\n                            Image img = new Bitmap(200, 200);\r\n                            Invoke(new Action(() =&gt; {\r\n                                il.Images.Add(img);\r\n                            }));\r\n                        }\r\n                    }\r\n\r\n                    string fileName = FileNameComp(Path.GetFileName(f), FileSizeUnit(new FileInfo(f).Length));\r\n                    var item = new ListViewItem(fileName , itemIndex);\r\n                    item.SubItems.Add(f);\r\n\r\n                    itemIndex++;\r\n\r\n                    Invoke((Action)(() =&gt; {\r\n                        Text = \"\u96c6\u8a08 (\" + itemIndex.ToString() + \"\u4ef6) : \" + needle;\r\n                        listView1.Items.Add(item);\r\n                    }));\r\n                }\r\n\r\n                Invoke(new Action(() =&gt;\r\n                {\r\n                    Text = \"\u5b8c\u4e86 (\" + (itemIndex).ToString() + \"\u4ef6) : \" + needle;\r\n                }));\r\n\r\n            }, token);\r\n\r\n            lock (LockObject)\r\n            {\r\n                IsExit = true;\r\n            }\r\n        }\r\n\r\n        private string FileSizeUnit(long b)\r\n        {\r\n            float k = b \/ 1024;\r\n            float m = k \/ 1024;\r\n            float g = m \/ 1024;\r\n            float t = g \/ 1024;\r\n\r\n            if (t &gt;= 1) return \"(\" + t.ToString(\"0.00\") + \"TB)\";\r\n            if (g &gt;= 1) return \"(\" + g.ToString(\"0.00\") + \"GB)\";\r\n            if (m &gt;= 1) return \"(\" + m.ToString(\"0.00\") + \"MB)\";\r\n            if (k &gt;= 1) return \"(\" + k.ToString(\"0.00\") + \"KB)\";\r\n\r\n            return \"\";\r\n        }\r\n\r\n        private string FileNameComp(string rawFileName, string fileSize)\r\n        {\r\n            string fileName = rawFileName;\r\n            while (TextRenderer.MeasureText(fileName + fileSize, new Font(\"\u30e1\u30a4\u30ea\u30aa\", 9)).Width &gt; 200)\r\n            {\r\n                fileName = fileName.Substring(0, fileName.Length - 1);\r\n            }\r\n            return fileName + fileSize;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\uff64fenrir(B@r09u3 Style Op.2)\u306e\u4ee3\u66ff\u3068\u3057\u3066\u81ea\u5206\u7528\u306b\u4f5c\u6210\u3057\u305f\u691c\u7d22\u30bd\u30d5\u30c8\u306b\u30b5\u30e0\u30cd\u30a4\u30eb\u6a5f\u80fd\u3092\u8ffd\u52a0\uff61 \u203b\u8ffd\u8a18(\u30d5\u30a1\u30a4\u30eb\u6dfb\u4ed8) Release20241118 \u4f7f\u3044\u65b9 \uff65\u89e3\u51cd\u5f8c\uff64ffmpeg.exe\u3092\u30d5 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=4379\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u30d5\u30a1\u30a4\u30eb\u691c\u7d22+\u6307\u5b9a\u79d2\u6570\u3067\u30b5\u30e0\u30cd\u30a4\u30eb\u4f5c\u6210(FFmpeg)&#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-4379","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\/4379","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=4379"}],"version-history":[{"count":18,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4379\/revisions"}],"predecessor-version":[{"id":6530,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4379\/revisions\/6530"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}