视频转bmp图片

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace 视频转bmp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public string path;
        List<Point> list = new List<Point>();
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "MP4文件(*.MP4)|*.MP4";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog1.FileName;
            }
            string str = System.Environment.CurrentDirectory;
            var str_MyProg = str + "\\ffmpeg\\bin\\ffmpeg.exe";
            string name = System.IO.Path.GetFileNameWithoutExtension(path);
            if (Directory.Exists("File\\" + name + "\\image"))
            {
                Directory.Delete("File\\" + name + "\\image", true);
                command(str, name, str_MyProg);
            }
            else
            {
                command(str, name, str_MyProg);
            }
        }
        void command(string str, string name, string str_MyProg)
        {
            Directory.CreateDirectory("File\\" + name + "\\image"); //创建此文件夹
            Directory.CreateDirectory("File\\" + name + "\\PSAF"); //创建此文件夹
            string save_folder = str + "\\File\\" + name + "\\image\\";
            //#设置参数以直接输出图像序列(帧)
            string str_CommandArgs = "-i " + path + " -vf fps=25/2 " + save_folder + "n_%03d.bmp"; //the n_%03d replaces "n++" count
            Process process = new Process();
            System.Diagnostics.ProcessStartInfo cmd_StartInfo = new System.Diagnostics.ProcessStartInfo(str_MyProg, str_CommandArgs);
            cmd_StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            cmd_StartInfo.RedirectStandardError = false; //set false
            cmd_StartInfo.RedirectStandardOutput = false; //set false
            cmd_StartInfo.UseShellExecute = true; //set true
            cmd_StartInfo.CreateNoWindow = true;  //don't need the black window
                                                  //创建一个进程,分配它的ProcessStartInfo并启动它
            System.Diagnostics.Process cmd = new System.Diagnostics.Process();
            cmd.StartInfo = cmd_StartInfo;
            cmd.Start();
        }

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值