-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the ability to split a video's original audio without encoding
This commit introduces the "raw" encoding mechanism, which does nothing except split the source audio into separate tracks without any encoding whatsoever. This option is perfect for those who prefer to simply split the audio into separate files in the original format. To use, simply use '--format raw' as the parameter.
- Loading branch information
1 parent
23f57d0
commit 3184658
Showing
7 changed files
with
92 additions
and
13 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
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,52 @@ | ||
/** | ||
* Copyright (C) 2021 Miris Wisdom | ||
* | ||
* This file is part of Gunloader. | ||
* | ||
* Gunloader is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2. | ||
* | ||
* Gunloader is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Gunloader. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
using System.Diagnostics; | ||
using System.IO; | ||
using static System.Diagnostics.Process; | ||
using static System.IO.Path; | ||
|
||
namespace Gunloader.Encoders | ||
{ | ||
public class RAW : Encoder | ||
{ | ||
public string Program { get; set; } = "ffmpeg"; | ||
|
||
public override FileInfo Encode(Track track, FileInfo audio = null, FileInfo cover = null) | ||
{ | ||
audio ??= new FileInfo(track.Number + ".wav"); | ||
var output = $"{GetFileNameWithoutExtension(track.Number)}{audio.Extension}"; | ||
|
||
/** | ||
* Split input audio into separate files of the same type, without any form of re-encoding. | ||
*/ | ||
|
||
Start(new ProcessStartInfo | ||
{ | ||
FileName = Program, | ||
Arguments = $"-ss {track.Start} " + | ||
$"{(string.IsNullOrWhiteSpace(track.End) ? "" : $"-to {track.End}")} " + | ||
$"-i {audio.Name} " + | ||
"-c:a copy " + | ||
$"{output}" | ||
})?.WaitForExit(); | ||
|
||
return new FileInfo(output); | ||
} | ||
} | ||
} |
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