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     退出

相关推荐
从孑开始6 小时前
ManySpeech.MoonshineAsr 使用指南
人工智能·ai·c#·.net·私有化部署·语音识别·onnx·asr·moonshine
YuanlongWang7 小时前
C# 中,依赖注入(DI)的实现方式
c#
SmartSoftHelp开发辅助优化8 小时前
C# WinForm 编程高手:程序,进程,线程。程序,窗体,UI,后台。是如何协调工作的?深度解析>SmartSoftHelp魔法精灵工作室
microsoft·ui·c#
future_studio10 小时前
聊聊 Unity(小白专享、C# 小程序 之 加密存储)
开发语言·小程序·c#
c#上位机11 小时前
MefBootstrapper在Prism引导程序中的使用
c#·wpf·prism
mortimer12 小时前
FFmpeg 音画同步实践记录:从切片、变速到拼接,彻底搞定时间轴
ffmpeg
给大佬递杯卡布奇诺12 小时前
FFmpeg 基本API avcodec_send_packet函数内部调用流程分析
c++·ffmpeg·音视频
玩泥巴的13 小时前
.NET驾驭Word之力:基于规则自动生成及排版Word文档
c#·word·.net·com互操作
酌量14 小时前
从 ROS 订阅视频话题到本地可视化与 RTMP 推流全流程实战
经验分享·笔记·ffmpeg·音视频·ros
SunnyDays101114 小时前
C# 实现高保真 Excel 转 PDF(无需 Office 环境)
经验分享·c#·excel转pdf