在.net中运用ffmpeg 操作视频

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.IO;

using System.Text;

namespace learun.util

{

/// <summary>

/// ffmpeg视频相关处理的类

/// </summary>

public class FFmpegUtil

{

public static int Run(string cmd)

{

try

{

//string ffmpeg = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"FFmpeg\ffmpeg.exe";

string ffmpeg = ConfigHelper.GetConfig().MultimediaFile.Replace("/", "\\") + @"FFmpeg\ffmpeg.exe";

ProcessStartInfo startInfo = new ProcessStartInfo(ffmpeg);

startInfo.UseShellExecute = false;

startInfo.CreateNoWindow = true;

startInfo.WindowStyle = ProcessWindowStyle.Hidden;

startInfo.Arguments = cmd;

Process process = Process.Start(startInfo);

//process.WaitForExit(3000);

process.Kill();

return 1;

}

catch (Exception ex)

{

return -1;

}

}

public static int Run1(string cmd)

{

int r = 0;

try

{

//string ffmpeg = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"FFmpeg\ffmpeg.exe";

string ffmpeg = ConfigHelper.GetConfig().MultimediaFile.Replace("/", "\\") + @"FFmpeg\ffmpeg.exe";

Process p = new Process();

p.StartInfo.FileName = ffmpeg;

p.StartInfo.Arguments = cmd;

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

string a = string.Empty;

p.ErrorDataReceived += new DataReceivedEventHandler((s, message) =>

{

//Response.Write(message.Data);

a = message.Data;

});//外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值