当前位置: 首页 > article >正文

ffmpeg 的视频格式转换 c# win10

1,下载ffmpeg ,并设置环境变量。

ffmpeghttps://www.gyan.dev/ffmpeg/builds/

2.新建.net 9.0  winform

using System;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;namespace WinFormsApp11
{public partial class Form1 : Form{public Form1(){InitializeComponent();}void StartPreview(){Process previewProcess = new Process();previewProcess.StartInfo.Arguments = " -i " + inputName + " -c:v " + bianma+ " " + outputName;// ffmpeg -i demo.avi -c:v libx264 output.mp4 previewProcess.StartInfo.FileName = "ffmpeg.exe";previewProcess.StartInfo.UseShellExecute = false;previewProcess.StartInfo.RedirectStandardInput = true;previewProcess.StartInfo.RedirectStandardOutput = true;previewProcess.StartInfo.RedirectStandardError = true;previewProcess.StartInfo.CreateNoWindow = true;previewProcess.Start();string output = previewProcess.StandardError.ReadToEnd();//很重要,不然不会自己退出previewProcess.WaitForExit();}string inputName = "";string outputName = "";string bianma = "libx264";private void button1_Click(object sender, EventArgs e){button1.Visible = false;inputName = textBox1.Text;textBox2.Text = Environment.CurrentDirectory + "\\" + System.DateTime.Now.ToString("yyyyMMdd_HHmmss") +"_"+bianma+ "_output.mkv";outputName = textBox2.Text;Task.Run(() =>{StartPreview();MessageBox.Show("转换完成");button1.BeginInvoke(new MethodInvoker(delegate (){button1.Visible = true;}));});}private void Form1_Load(object sender, EventArgs e){comboBox1.SelectedIndex = 0;inputName = System.DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_input.avi";outputName = System.DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_output.mkv";textBox1.Text = inputName;textBox2.Text = outputName;}private void button2_Click(object sender, EventArgs e){OpenFileDialog openFileDialog = new OpenFileDialog();// 设置对话框标题openFileDialog.Title = "选择一个视频文件";openFileDialog.Filter = "视频文件 (*.avi,*.mp4,*.mkv)|*.avi;*.mp4;*.mkv|所有文件 (*.*)|*.*";if (openFileDialog.ShowDialog() == DialogResult.OK){// 获取用户选择的文件路径inputName = openFileDialog.FileName;textBox1.Text = openFileDialog.FileName;}}private void comboBox1_SelectedIndexChanged(object sender, EventArgs e){if (comboBox1.Text == "libx264") { bianma = "libx264"; }if (comboBox1.Text == "libx265") { bianma = "libx265"; }}}}

   string output = previewProcess.StandardError.ReadToEnd();//很重要,不然不会自己退出

整个工程下载:

【免费】ffmpeg的视频格式转换c#win10资源-CSDN文库https://download.csdn.net/download/vokxchh/90947301

http://www.lryc.cn/news/2396887.html

相关文章:

  • 【irregular swap】An Examination of Fairness of AI Models for Deepfake Detection
  • 【JAVA】注解+元注解+自定义注解(万字详解)
  • 【Doris基础】Apache Doris中的Version概念解析:深入理解数据版本管理机制
  • 【Linux 基础知识系列】第一篇-Linux 简介与历史
  • 【图像处理基石】如何进行图像畸变校正?
  • 软件开发项目管理工具选型及禅道开源版安装
  • 【架构艺术】平衡技术架构设计和预期的产品形态
  • 电力系统时间同步系统
  • Vue使用toFixed保留两位小数的三种写法
  • 华为云【Astro zero】如何做“设备编辑”页面
  • Arch安装botw-save-state
  • 电脑为什么换个ip就上不了网了
  • NULL与空字符串的区别:数据库专家详解
  • github 2FA双重认证丢失解决
  • linux驱动 - 5: simple usb device驱动
  • OpenCV CUDA模块直方图计算------在 GPU 上计算输入图像的直方图(histogram)函数histEven()
  • QT/c++航空返修数据智能分析系统
  • Spring Security架构中过滤器的实现
  • Playwright Python API 测试:从入门到实践
  • ETL脚本节点使用的方式
  • PH热榜 | 2025-06-02
  • Domain Adaptation in Vision-Language Models (2023–2025): A Comprehensive Review
  • 容器化革命:告别传统Dockerfile,拥抱现代构建最佳实践
  • : influxdb + grafana+JMeter
  • Vue拖拽组件:vue-draggable-plus
  • TDengine 基于 TDgpt 的 AI 应用实战
  • RocketMQ 消息发送核心源码解析:DefaultMQProducerImpl.send () 方法深度剖析
  • BiliNote部署实践
  • deepseek问答记录:请讲解一下transformers.HfArgumentParser()
  • bismark OT CTOT OB CTOB 以及mapping后的bam文件中的XG,XR列的含义