mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
Fix keepAudio/keepSubs config options
This commit is contained in:
@@ -207,31 +207,15 @@ namespace Flowframes.Main
|
||||
return times;
|
||||
}
|
||||
|
||||
public static async Task MergeAudio(string inputPath, string outVideo, int looptimes = -1)
|
||||
public static async Task MergeAudio(string inputPath, string outVideo)
|
||||
{
|
||||
if (!Config.GetBool("keepAudio")) return;
|
||||
|
||||
try
|
||||
{
|
||||
string audioFileBasePath = Path.Combine(I.current.tempFolder, "audio");
|
||||
|
||||
if (inputPath != null && IOUtils.IsPathDirectory(inputPath) && !File.Exists(IOUtils.GetAudioFile(audioFileBasePath))) // Try loading out of same folder as input if input is a folder
|
||||
audioFileBasePath = Path.Combine(I.current.tempFolder.GetParentDir(), "audio");
|
||||
|
||||
// if (!File.Exists(IOUtils.GetAudioFile(audioFileBasePath)))
|
||||
// await FfmpegAudioAndMetadata.ExtractAudioTracks(inputPath, audioFileBasePath); // Extract from sourceVideo to audioFile unless it already exists
|
||||
|
||||
// if (!File.Exists(IOUtils.GetAudioFile(audioFileBasePath)) || new FileInfo(IOUtils.GetAudioFile(audioFileBasePath)).Length < 4096)
|
||||
// {
|
||||
// Logger.Log("Can't merge audio as there's no extracted audio file in the temp folder.", true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
await FfmpegAudioAndMetadata.MergeAudioAndSubs(outVideo, I.current.tempFolder); // Merge from audioFile into outVideo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Failed to copy audio!");
|
||||
Logger.Log("Failed to merge audio/subtitles with output video!");
|
||||
Logger.Log("MergeAudio() Exception: " + e.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,15 +106,20 @@ namespace Flowframes
|
||||
Utils.FixConsecutiveSceneFrames(Path.Combine(current.tempFolder, Paths.scenesDir), current.framesFolder);
|
||||
|
||||
if (canceled) return;
|
||||
Program.mainForm.SetStatus("Extracting audio from video...");
|
||||
//string audioFile = Path.Combine(current.tempFolder, "audio");
|
||||
|
||||
//if (audioFile != null && !File.Exists(audioFile))
|
||||
await FfmpegAudioAndMetadata.ExtractAudioTracks(inPath, current.tempFolder);
|
||||
if (Config.GetBool("keepAudio"))
|
||||
{
|
||||
Program.mainForm.SetStatus("Extracting audio from video...");
|
||||
await FfmpegAudioAndMetadata.ExtractAudioTracks(inPath, current.tempFolder);
|
||||
}
|
||||
|
||||
if (canceled) return;
|
||||
Program.mainForm.SetStatus("Extracting subtitles from video...");
|
||||
await FfmpegAudioAndMetadata.ExtractSubtitles(inPath, current.tempFolder, current.outMode);
|
||||
|
||||
if (Config.GetBool("keepSubs"))
|
||||
{
|
||||
Program.mainForm.SetStatus("Extracting subtitles from video...");
|
||||
await FfmpegAudioAndMetadata.ExtractSubtitles(inPath, current.tempFolder, current.outMode);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task PostProcessFrames (bool stepByStep)
|
||||
|
||||
@@ -156,7 +156,6 @@ namespace Flowframes.Media
|
||||
|
||||
public static async Task MergeAudioAndSubs(string inputFile, string tempFolder) // https://superuser.com/a/277667
|
||||
{
|
||||
// Logger.Log($"[FFCmds] Merging audio from {audioPath} into {inputFile}", true);
|
||||
string containerExt = Path.GetExtension(inputFile);
|
||||
string tempPath = Path.Combine(tempFolder, $"vid{containerExt}");
|
||||
string outPath = Path.Combine(tempFolder, $"muxed{containerExt}");
|
||||
@@ -164,8 +163,11 @@ namespace Flowframes.Media
|
||||
string inName = Path.GetFileName(tempPath);
|
||||
string outName = Path.GetFileName(outPath);
|
||||
|
||||
string[] audioTracks = IOUtils.GetFilesSorted(tempFolder, false, "*_audio.*"); // Find audio files
|
||||
string[] subTracks = IOUtils.GetFilesSorted(tempFolder, false, "*.srt"); // Find subtitle files
|
||||
bool audio = Config.GetBool("keepAudio");
|
||||
bool subs = Utils.ContainerSupportsSubs(containerExt, false) && Config.GetBool("keepSubs");
|
||||
|
||||
string[] audioTracks = audio ? IOUtils.GetFilesSorted(tempFolder, false, "*_audio.*") : new string[0]; // Find audio files
|
||||
string[] subTracks = subs ? IOUtils.GetFilesSorted(tempFolder, false, "*.srt") : new string[0]; // Find subtitle files
|
||||
|
||||
Dictionary<int, string> trackFiles = new Dictionary<int, string>(); // Dict holding all track files with their index
|
||||
|
||||
@@ -175,9 +177,6 @@ namespace Flowframes.Media
|
||||
foreach (string subTrack in subTracks) // Loop through subtitle streams to add them to the dict
|
||||
trackFiles[Path.GetFileNameWithoutExtension(subTrack).Split('_')[0].GetInt()] = subTrack; // Add file, dict key is stream index
|
||||
|
||||
bool audio = Config.GetBool("keepSubs");
|
||||
bool subs = Utils.ContainerSupportsSubs(containerExt, false) && Config.GetBool("keepSubs");
|
||||
|
||||
string trackInputArgs = "";
|
||||
string trackMapArgs = "";
|
||||
string trackMetaArgs = "";
|
||||
|
||||
Reference in New Issue
Block a user