ちょっと動画の長さを調整したいとき用。
実行ファイルと同じ場所にffmpeg.exeを置く。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; using QuartzTypeLib; namespace FFMPEG_UI { public partial class Form1 : Form { public Form1() { InitializeComponent(); listBox1.AllowDrop = true; textBox1.Text = "00"; textBox2.Text = "00"; textBox3.Text = "00"; textBox4.Text = "000"; textBox5.Text = "00"; textBox6.Text = "00"; textBox7.Text = "00"; textBox8.Text = "000"; } private void listBox1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; } private void listBox1_DragDrop(object sender, DragEventArgs e) { listBox1.Items.AddRange((string[])e.Data.GetData(DataFormats.FileDrop, false)); } private void button2_Click(object sender, EventArgs e) { listBox1.Items.Clear(); textBox1.Text = "00"; textBox2.Text = "00"; textBox3.Text = "00"; textBox4.Text = "000"; textBox5.Text = "00"; textBox6.Text = "00"; textBox7.Text = "00"; textBox8.Text = "000"; } private void button1_Click(object sender, EventArgs e) { string s_h = textBox1.Text; string s_m = textBox2.Text; string s_s = textBox3.Text; string s_ms = textBox4.Text; string e_h = textBox5.Text; string e_m = textBox6.Text; string e_s = textBox7.Text; string e_ms = textBox8.Text; TimeSpan start_position = new TimeSpan(0, int.Parse(s_h), int.Parse(s_m), int.Parse(s_s), int.Parse(s_ms)); TimeSpan end_position = new TimeSpan(0, int.Parse(e_h), int.Parse(e_m), int.Parse(e_s), int.Parse(e_ms)); string interval = (end_position - start_position).TotalSeconds.ToString(); foreach (string s in listBox1.Items) { string filePath = System.IO.Path.GetDirectoryName(s) + @"\out_" + System.IO.Path.GetFileName(s); System.Diagnostics.Process p = System.Diagnostics.Process.Start( Application.StartupPath + @"\ffmpeg.exe" , "-ss " + start_position.TotalSeconds.ToString() + " -i \"" + s.ToString() + "\" -t " + interval + " \"" + filePath + "\""); p.WaitForExit(); } } } } |