diff --git a/cmd/soundscape-sync/main.go b/cmd/soundscape-sync/main.go deleted file mode 100644 index 50e4dfd..0000000 --- a/cmd/soundscape-sync/main.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "fyne.io/fyne/v2" - "fyne.io/fyne/v2/app" - "soundscape-sync/internal/ui" -) - -func main() { - myApp := app.New() - mainWindow := myApp.NewWindow("Soundscape Sync") - - content := ui.CreateMainContent(mainWindow) - mainWindow.SetContent(content) - - mainWindow.Resize(fyne.NewSize(800, 600)) - mainWindow.ShowAndRun() -} diff --git a/internal/logic/sync-5.1.go b/internal/logic/sync-5.1.go new file mode 100644 index 0000000..d678421 --- /dev/null +++ b/internal/logic/sync-5.1.go @@ -0,0 +1,12 @@ +package logic + +func get5_1Arguments() []string { + return []string{ + // best audio format so far on ios + "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2[out]", + "-c:a", "aac", "-b:a", "654k", + // mp4 output + // "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=5.1|c0=c0+c6|c1=c1+c7|c2=c2|c3=c3|c4=c4|c5=c5[out]", + // "-c:a", "eac3", "-ac", "6", + } +} diff --git a/internal/logic/sync-7.1.4.go b/internal/logic/sync-7.1.4.go new file mode 100644 index 0000000..2906f3c --- /dev/null +++ b/internal/logic/sync-7.1.4.go @@ -0,0 +1,8 @@ +package logic + +func get7_1_4Arguments() []string { + return []string{ + "-filter_complex", + "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=7.1.4|FL=c0+c12|FR=c1+c13|FC=c2|LFE=c3|BL=c6|BR=c7|SL=c4|SR=c5|TFL=c8|TFR=c9|TBL=c10|TBR=c11[out]", + } +} diff --git a/internal/logic/sync-atmos.go b/internal/logic/sync-atmos.go deleted file mode 100644 index d30140b..0000000 --- a/internal/logic/sync-atmos.go +++ /dev/null @@ -1,99 +0,0 @@ -package logic - -import ( - "context" - "fmt" - "os/exec" - "path/filepath" - - "fyne.io/fyne/v2/widget" -) - -func combineAtmosFiles(folder1 string, folder2 string, outputFolder string, progress *widget.ProgressBar) error { - // Get list of audio files from both folders - files1, err := getAudioFiles(folder1) - if err != nil { - return err - } - files2, err := getAudioFiles(folder2) - if err != nil { - return err - } - - if len(files1) != len(files2) { - return fmt.Errorf("the number of audio files in the two folders must be the same") - } - - ffmpegPath, err := getFFmpegPath() - if err != nil { - return err - } - - total := len(files1) - - for index, file := range files1 { - duration, err := getDuration(file) - if err != nil { - return err - } - - // Get extension of file - // ext := filepath.Ext(file) - - // Get output file name - newFileName := outputFolder + "/" + filepath.Base(files2[index]) - newFileName = newFileName[:len(newFileName)-4] + "_synced.m4v" - - // coverArtString, err := getCoverArtString(file) - // if err != nil { - // return err - // } - - - // Construct FFmpeg command - ctx, _ := context.WithCancel(context.Background()) - arguments := []string{ - "-i", file, - "-i", files2[index], - // best audio format so far on ios - "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2[out]", - "-c:a", "aac", "-b:a", "654k", - // mp4 output - // "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=5.1|c0=c0+c6|c1=c1+c7|c2=c2|c3=c3|c4=c4|c5=c5[out]", - // "-c:a", "eac3", "-ac", "6", - } - arguments = append(arguments, getBaseArguments()...) - arguments = append(arguments, getCoverArtArguments(file, files2[index])...) - arguments = append(arguments, newFileName) - // map channel 1 and 2 of file 2 to channel 1 and 2 of file 1 but keep all other channels of file 1 - // it will be a 6 channel atmos output file - cmd := exec.CommandContext(ctx, ffmpegPath, arguments...) - cmd.SysProcAttr = getSysProcAttr() - stdout, err := cmd.StdoutPipe() - if err != nil { - // prepend error with text - err = fmt.Errorf("error creating ffmpeg command: %w", err) - return err - } - - // Execute FFmpeg command - if err := cmd.Start(); err != nil { - err = fmt.Errorf("error at ffmpeg command start: %w", err) - return err - } - - parseProgress(index, total, progress, stdout, duration) - - if err := cmd.Wait(); err != nil { - err = fmt.Errorf("error at ffmpeg command wait: %w", err) - return err - } - } - - cleanupTemp() - - progress.SetValue(1.0) - return nil -} - - diff --git a/internal/logic/sync-stereo.go b/internal/logic/sync-stereo.go index 42a5542..1a4e588 100644 --- a/internal/logic/sync-stereo.go +++ b/internal/logic/sync-stereo.go @@ -1,90 +1,7 @@ package logic -import ( - "context" - "fmt" - "os/exec" - "path/filepath" - - "fyne.io/fyne/v2/widget" -) - -func combineStereoFiles(folder1 string, folder2 string, outputFolder string, progress *widget.ProgressBar) error { - // Get list of audio files from both folders - files1, err := getAudioFiles(folder1) - if err != nil { - return err - } - files2, err := getAudioFiles(folder2) - if err != nil { - return err - } - - if len(files1) != len(files2) { - return fmt.Errorf("the number of audio files in the two folders must be the same") - } - - ffmpegPath, err := getFFmpegPath() - if err != nil { - return err - } - - total := len(files1) - - for index, file := range files1 { - duration, err := getDuration(file) - if err != nil { - return err - } - - // Construct FFmpeg command - ext := filepath.Ext(files2[index]) - newFileName := outputFolder + "/" + filepath.Base(files2[index]) - newFileName = newFileName[:len(newFileName)-4] + "_synced" + ext - ctx, _ := context.WithCancel(context.Background()) - arguments := []string{ - "-i", file, - "-i", files2[index], +func getStereoArguments() []string { + return []string{ "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=stereo|c0