This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc720fa
commit 0eec186
Showing
8 changed files
with
127 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Captura.Models; | ||
|
||
namespace Captura.FFmpeg | ||
{ | ||
public class FFmpegTrimmer | ||
{ | ||
public async Task Run(string SourceFile, | ||
TimeSpan From, | ||
TimeSpan To, | ||
string DestFile, | ||
bool HasAudio) | ||
{ | ||
var argsBuilder = new FFmpegArgsBuilder(); | ||
|
||
var inputArgs = argsBuilder.AddInputFile(SourceFile) | ||
.AddArg($"-ss {From}") | ||
.AddArg($"-to {To}"); | ||
|
||
if (HasAudio) | ||
inputArgs.SetAudioCodec("copy"); | ||
|
||
argsBuilder.AddOutputFile(DestFile); | ||
|
||
var args = argsBuilder.GetArgs(); | ||
|
||
var process = FFmpegService.StartFFmpeg(args, DestFile); | ||
|
||
await Task.Factory.StartNew(process.WaitForExit); | ||
|
||
if (process.ExitCode != 0) | ||
{ | ||
throw new FFmpegException(process.ExitCode); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.