{"id":1989,"date":"2017-10-31T19:44:46","date_gmt":"2017-10-31T10:44:46","guid":{"rendered":"http:\/\/okamurax.com\/?p=1989"},"modified":"2024-05-03T18:59:15","modified_gmt":"2024-05-03T09:59:15","slug":"c-ffmpeg%e3%81%ab%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e6%8a%95%e3%81%92%e3%82%8b","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=1989","title":{"rendered":"C# FFmpeg\u306b\u30b3\u30de\u30f3\u30c9\u6295\u3052\u308b\u2461"},"content":{"rendered":"<p>\u3061\u3087\u3063\u3068\u52d5\u753b\u306e\u9577\u3055\u3092\u8abf\u6574\u3057\u305f\u3044\u3068\u304d\u7528\u3002<\/p>\n<p>\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u5834\u6240\u306bffmpeg.exe\u3092\u7f6e\u304f\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\nusing System.Runtime.InteropServices;\r\nusing QuartzTypeLib;\r\n\r\nnamespace FFMPEG_UI\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            listBox1.AllowDrop = true;\r\n\r\n            textBox1.Text = \"00\";\r\n            textBox2.Text = \"00\";\r\n            textBox3.Text = \"00\";\r\n            textBox4.Text = \"000\";\r\n            textBox5.Text = \"00\";\r\n            textBox6.Text = \"00\";\r\n            textBox7.Text = \"00\";\r\n            textBox8.Text = \"000\";\r\n        }\r\n\r\n        private void listBox1_DragEnter(object sender, DragEventArgs e)\r\n        {\r\n            if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;\r\n        }\r\n\r\n        private void listBox1_DragDrop(object sender, DragEventArgs e)\r\n        {\r\n            listBox1.Items.AddRange((string[])e.Data.GetData(DataFormats.FileDrop, false));\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            listBox1.Items.Clear();\r\n\r\n            textBox1.Text = \"00\";\r\n            textBox2.Text = \"00\";\r\n            textBox3.Text = \"00\";\r\n            textBox4.Text = \"000\";\r\n            textBox5.Text = \"00\";\r\n            textBox6.Text = \"00\";\r\n            textBox7.Text = \"00\";\r\n            textBox8.Text = \"000\";\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            string s_h = textBox1.Text;\r\n            string s_m = textBox2.Text;\r\n            string s_s = textBox3.Text;\r\n            string s_ms = textBox4.Text;\r\n            string e_h = textBox5.Text;\r\n            string e_m = textBox6.Text;\r\n            string e_s = textBox7.Text;\r\n            string e_ms = textBox8.Text;\r\n\r\n            TimeSpan start_position = new TimeSpan(0, int.Parse(s_h), int.Parse(s_m), int.Parse(s_s), int.Parse(s_ms));\r\n            TimeSpan end_position = new TimeSpan(0, int.Parse(e_h), int.Parse(e_m), int.Parse(e_s), int.Parse(e_ms));\r\n            string interval = (end_position - start_position).TotalSeconds.ToString();\r\n\r\n            foreach (string s in listBox1.Items)\r\n            {\r\n\r\n                string filePath = System.IO.Path.GetDirectoryName(s) + @\"\\out_\" + System.IO.Path.GetFileName(s);\r\n                \r\n                System.Diagnostics.Process p =\r\n                System.Diagnostics.Process.Start(\r\n                    Application.StartupPath + @\"\\ffmpeg.exe\"\r\n                    , \"-ss \" + start_position.TotalSeconds.ToString() + \" -i \\\"\" + s.ToString() + \"\\\" -t \" + interval + \" \\\"\" + filePath + \"\\\"\");\r\n\r\n                p.WaitForExit();\r\n                \r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3061\u3087\u3063\u3068\u52d5\u753b\u306e\u9577\u3055\u3092\u8abf\u6574\u3057\u305f\u3044\u3068\u304d\u7528\u3002 \u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u5834\u6240\u306bffmpeg.exe\u3092\u7f6e\u304f\u3002 using System; using System.Collections.Generic; using System.Co &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=1989\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# FFmpeg\u306b\u30b3\u30de\u30f3\u30c9\u6295\u3052\u308b\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-1989","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\/1989","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=1989"}],"version-history":[{"count":8,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1989\/revisions"}],"predecessor-version":[{"id":6299,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1989\/revisions\/6299"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}