Skip to content

Commit

Permalink
[FIX] dont cut off soundscape if its longer than the audiobook
Browse files Browse the repository at this point in the history
  • Loading branch information
dpolakovics committed Nov 6, 2024
1 parent 6b0fc3d commit 77ea314
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions internal/logic/sync-atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,23 @@ func combineAtmosFiles(folder1 string, folder2 string, outputFolder string, prog
newFileName := outputFolder + "/" + filepath.Base(files2[index])
newFileName = newFileName[:len(newFileName)-4] + "_synced" + ext

coverArtString, err := getCoverArtString(file)
if err != nil {
return err
}
// coverArtString, err := getCoverArtString(file)
// if err != nil {
// return err
// }

// Construct FFmpeg command
ctx, _ := context.WithCancel(context.Background())
// 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,
"-i", file,
"-i", files2[index],
"-filter_complex", "[0:a][1:a]amerge=inputs=2,pan=5.1|c0=c0+c6|c1=c1+c7|c2=c2|c3=c3|c4=c4|c5=c5[out]",
"-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]",
"-map", "[out]",
"-c:a", "eac3",
"-map", coverArtString, "-c:v", "copy", "-disposition:v", "attached_pic",
// "-map", "2:0", "-metadata:s:v", "title=\"Album cover\"", "-metadata:s:v", "comment=\"Cover (front)\"",
// "-map", "-map", coverArtString + ":v", "-c:v", "copy", "-disposition:v:1", "attached_pic",
"-metadata:s:a:0", "encoder=\"Dolby Digital Plus + Dolby Atmos\"",
"-progress",
"pipe:1",
Expand Down
4 changes: 2 additions & 2 deletions internal/logic/sync-stereo.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func combineStereoFiles(folder1 string, folder2 string, outputFolder string, pro
cmd := exec.CommandContext(ctx, ffmpegPath,
"-i", file,
"-i", files2[index],
"-filter_complex", "[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[a]",
"-map", coverArtString, "-c:v", "copy", "-disposition:v", "attached_pic",
"-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[a]",
"-map", coverArtString + ":v", "-c:v", "copy", "-disposition:v", "attached_pic",
"-progress",
"pipe:1",
"-map", "[a]",
Expand Down
4 changes: 2 additions & 2 deletions internal/logic/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func parseProgress(index int, total int, progress *widget.ProgressBar, reader io

func getCoverArtString(filePath string) (string, error) {
// Open the audio file
coverArtString := "1:v"
coverArtString := "1"
f, err := os.Open(filePath)
if err != nil {
return coverArtString, err
Expand All @@ -113,7 +113,7 @@ func getCoverArtString(filePath string) (string, error) {

// Check if there is any artwork
if metadata.Picture() != nil {
coverArtString = "0:v"
coverArtString = "0"
}
return coverArtString, nil
}

0 comments on commit 77ea314

Please sign in to comment.