fix: video visualizer

This commit is contained in:
Karma Riuk 2023-08-28 11:57:40 +02:00
parent 77843db6de
commit 2e8ccce703

View File

@ -8,7 +8,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"sync"
"github.com/mazznoer/colorgrad" "github.com/mazznoer/colorgrad"
) )
@ -35,11 +34,8 @@ func (v *VideoVisualizer) Visualize(solved_chan <-chan *maze.SolvedMaze) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
var wg sync.WaitGroup
i := 0 i := 0
for solved := range solved_chan { for solved := range solved_chan {
wg.Add(1)
go func() {
img_writer := writer.ImageWriter{ img_writer := writer.ImageWriter{
Filename: path.Join(tmp_dir, fmt.Sprintf("%07v.png", i)), Filename: path.Join(tmp_dir, fmt.Sprintf("%07v.png", i)),
Maze: solved, Maze: solved,
@ -50,11 +46,8 @@ func (v *VideoVisualizer) Visualize(solved_chan <-chan *maze.SolvedMaze) {
SolutionGradient: colorgrad.Warm(), SolutionGradient: colorgrad.Warm(),
} }
img_writer.Write() img_writer.Write()
wg.Done()
}()
i++ i++
} }
wg.Wait()
cmd := exec.Command( cmd := exec.Command(
v.ffmpeg_cmd, v.ffmpeg_cmd,
"-y", "-y",