-
-
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.
Merge pull request #9 from dpolakovics/add-7.1.4
feat: add 7.1.4 and refactor a bit
- Loading branch information
Showing
6 changed files
with
130 additions
and
231 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,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", | ||
} | ||
} |
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,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]", | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -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<c0+c2|c1<c1+c3[out]", | ||
} | ||
arguments = append(arguments, getBaseArguments()...) | ||
arguments = append(arguments, getCoverArtArguments(file, files2[index])...) | ||
arguments = append(arguments, newFileName) | ||
cmd := exec.CommandContext(ctx, ffmpegPath, arguments...) | ||
cmd.SysProcAttr = getSysProcAttr() | ||
stdout, err := cmd.StdoutPipe() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Execute FFmpeg command | ||
if err := cmd.Start(); err != nil { | ||
return err | ||
} | ||
|
||
parseProgress(index, total, progress, stdout, duration) | ||
|
||
if err := cmd.Wait(); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
cleanupTemp() | ||
|
||
progress.SetValue(1.0) | ||
return nil | ||
} | ||
|
||
func getCoverArtFromMp3 (filename string) error { | ||
ffmpegPath, err := getFFmpegPath() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd := exec.Command(ffmpegPath, "-i", filename, "cover.jpg") | ||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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