开发者

How to cut/crop/trim a video in respect with time or percentage and save output in different file

Is there any tutorial or a c# library which which help me to accomplish the following

  1. Chose a file to edit
  2. Ask user to select cut/crop/trim method :- by time or by percentage
  3. cut/crop/trim the video by time or percentage as chosen ( say I wish to reduce a 5 minute video to 4 minute video, or reduce the video by 80%)
  4. Save the video as requested in required path

now steps 1) and 4) I have implemented but could not find a good c# library to accomplish 3) and 4)

I looked up the ffmpeg library but could not find a开发者_Python百科 good C# wrapper to accomplish the requirements.


ffmpeg is a very powerful application and I have used it many times, even from C#. You don't need a C# wrapper library. All you have to do is execute the ffmpeg commands from C# using:

System.Diagnostics.Process.Start(string fileName, string arguments);

Or use System.Diagnostics.ProcessStartInfo to redirect standard output if you need to.

This article explains how to use System.Diagnostics to execute synchronous and asynchronous commands, etc.
http://www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx

Here's a simple example of how to cut a video file down to its first 4 minutes using ffmpeg from C#.

using System.Diagnostics
Process.Start("ffmpeg.exe",
              "-sameq -t 240 -i InputVideoFile.avi OutputVideoFile.avi");

Here's a SO example of how to use System.Diagnostics.ProcessStartInfo
C# and FFmpeg preferably without shell commands?

There are lots of online resources that explain all of ffmpeg's features and how to use them, just search.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜