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

相关推荐
落寞的星星4 小时前
这个对象就包含了已经转换好的DFA和各种词法分析器运转所需要的参数。下一步,我们就可以用ScannerInfo对象创建出Scanner对象,请看下面的代码:
开发语言·c#
聪慧的水蜜桃8 小时前
【YFIOs】用C#开发硬件之设备上云
开发语言·c#
hixiong12313 小时前
TensorRT转换工具分享
人工智能·计算机视觉·ai·c#
莫生灬灬14 小时前
DY联系人聊天Web面板支持获取联系人/聊天记录/发送消息
前端·chrome·websocket·c#
阿拉斯攀登15 小时前
售货柜实战:IPC 拉流 → 抽帧 → YOLO 识别完整流水线
yolo·ffmpeg·音视频·webrtc·视频编解码
逝水无殇16 小时前
C# 多态性详解
开发语言·后端·c#
逝水无殇16 小时前
C# 继承(Inheritance)详解
开发语言·后端·c#
阿拉斯攀登18 小时前
RTSP 拉流与录制:IPC 摄像头本地录像完整方案
ffmpeg·音视频·webrtc·实时音视频·视频编解码
asdzx6719 小时前
C# 通过模板生成 Word 文档:文本与图片占位符替换完整攻略
开发语言·c#·word
影寂ldy19 小时前
C# 泛型协变与逆变
windows·microsoft·c#