mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
add audio export
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using Avalonia.Data.Converters;
|
||||
using FFMpegCore;
|
||||
using MercuryConverter.Data;
|
||||
using MercuryConverter.UI.Views;
|
||||
using MercuryConverter.Utility;
|
||||
using SaturnData.Notation.Serialization;
|
||||
|
||||
namespace MercuryConverter.ExportOperation;
|
||||
@@ -54,6 +51,8 @@ public class Exporter
|
||||
/// AUDIO ///
|
||||
var audioKey = ec.Item1.AudioPath;
|
||||
var audioExportFileName = $"{audioKey}.{options.AudioFormat.ToString().ToLower()}";
|
||||
var audioExportPath = Path.Combine(exportSongPath, audioExportFileName);
|
||||
Console.WriteLine(audioExportFileName);
|
||||
if (!finishedAudio.Contains(audioKey) && Database.AudioPaths.ContainsKey(audioKey))
|
||||
{
|
||||
var audioSourcePath = Database.AudioPaths[audioKey];
|
||||
@@ -61,12 +60,14 @@ public class Exporter
|
||||
// Copy/convert audio -- TODO
|
||||
switch (options.AudioFormat)
|
||||
{
|
||||
case AudioFormat.MP3:
|
||||
break;
|
||||
case AudioFormat.OGG:
|
||||
case AudioFormat.WAV:
|
||||
File.Copy(audioSourcePath, audioExportPath, true);
|
||||
break;
|
||||
default:
|
||||
File.Copy(audioSourcePath, Path.Combine(exportSongPath, audioExportFileName), true);
|
||||
FFMpegArguments
|
||||
.FromFileInput(audioSourcePath)
|
||||
.OutputToFile(audioExportPath)
|
||||
.ProcessSynchronously();
|
||||
break;
|
||||
}
|
||||
finishedAudio.Add(audioKey);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -11,7 +9,6 @@ using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using MercuryConverter.Data;
|
||||
@@ -151,7 +148,7 @@ public partial class Export : Panel
|
||||
int.TryParse(NumThreads.Text, out var thr) && 1 <= thr && thr <= Environment.ProcessorCount
|
||||
);
|
||||
|
||||
var ffmpegAvail = Utils.IsFFMpegAvailable();
|
||||
var ffmpegAvail = Utils.FFMpegAvailable;
|
||||
if (!ffmpegAvail)
|
||||
RadioLeaveAudioWAV.IsChecked = true;
|
||||
RadioLeaveAudioWAV.IsEnabled = ffmpegAvail;
|
||||
|
||||
Reference in New Issue
Block a user