C#:直接调用 OpenFileDialog

C# 直接调用 OpenFileDialog,打开文件夹,选择视频文件,并播放。

编写 openvideo.cs 如下

cs 复制代码
// open a video file
using System;
using System.Diagnostics;
using System.Windows.Forms;
 
public class OpenVideoFile
{
    [STAThread]
    public static void Main()
    {
        OpenFileDialog ofd = new OpenFileDialog();
 
        // 设置对话框属性
        ofd.Title = "请选择Video文件";
        // 设置初始目录
        ofd.InitialDirectory = "D:\\VIDEO";
        // 设置文件过滤器
        ofd.Filter = "avi files (*.avi)|*.avi|All files (*.*)|*.*";
        ofd.FilterIndex = 1; // 设置默认的文件过滤器索引
        ofd.RestoreDirectory = true; // 设置在关闭对话框前还原目录
 
        if (ofd.ShowDialog() == DialogResult.OK) // 显示对话框
        {
            // 获取选中的文件路径
            string filePath = ofd.FileName;
            ProcessStartInfo startInfo = new ProcessStartInfo("D:\\FFModules\\Encoder\\mplayer.exe");
            startInfo.Arguments = " -aspect 4:3 " +filePath;
            startInfo.UseShellExecute = false;
        
            Process process = Process.Start(startInfo);
            process.WaitForExit();
        } else {
            Console.WriteLine("Select null");
        }
    }
}

where csc

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe

编译 csc /r:System.Windows.Forms.dll /target:winexe openvideo.cs

运行 openvideo

如果你的PC安装了【 格式工厂】这个应用软件,那么实际安装了Windows版的 FFmpeg

在D:\FormatFactory\FFModules\Encoder\ 能找到 mplayer.exe 和 ffmpeg.exe

这里谈谈 mplayer 简单应用:mplayer -h

  1. 播放比例调整

mplayer -aspect 16:9 <videofile>

mplayer -aspect 4:3 <videofile>

  1. 控制热键

基本播放

→     前进10秒

←     后退10秒

↑     前进60秒

↓     后退60秒

PageUP  前进10分钟

PageDown 后退10分钟

Enter   全屏开关

Space   暂停开关

Esc    退出

q     退出

相关推荐
淡海水1 小时前
07-01-源码-.NET Core GC总览与架构
unity·架构·c#·.netcore·gc
OH_TPC1 小时前
【鸿蒙优选三方库】@ohos/ffmpeg-kit:把 FFmpeg 的全部能量带进鸿蒙
华为·ffmpeg·harmonyos·鸿蒙
是jin奥1 小时前
最新 FFmpeg 安装脚本:Linux x86_64
linux·运维·ffmpeg
骑着蜗牛撵大象3273 小时前
用 Codex 批量做数字人商品口播视频:从分镜 JSON 到成片校验的流水线
java·ffmpeg·json·音视频·数字人·视频·codex
weixin_416660073 小时前
Mermaid流程图导出到Word:SVG、PNG与清晰度如何选择?
开发语言·c#
企业数字化笔记5 小时前
视频加放大特写后音画不同步怎么办?OpenCV转场与FFmpeg音轨续接实战
opencv·ffmpeg·音视频
公子小六5 小时前
基于.NET的Windows窗体编程之WinForms自定义控件(3)
windows·c#·.net·音视频·winforms
光泽雨1 天前
动画生命周期
c#·wpf
波力海苔夹心脆6751 天前
C# StringBuilder 详解:字符串拼接为什么总说要用它?
开发语言·笔记·c#·.net·字符串·stringbuilder·入门教程
淡海水1 天前
06-03-源码-时间分片与调度策略
unity·c#·gc