use fmt.Fprintf to write to the file directly

...instead of creating a new string with `fmt.Sprintf` and writing it
with to the file separately.
This commit is contained in:
tocariimaa 2025-01-01 13:31:56 -03:00
parent ab3b47d66b
commit 2b0a0dbcf5

View file

@ -17,12 +17,12 @@ func makeConcatDemuxFile(manifest UgoiraManifest, frameDescFile *os.File) {
frames := manifest.Body.Frames frames := manifest.Body.Frames
for _, frame := range frames { for _, frame := range frames {
frameDur := float32(frame.Delay) / 1000 // convert to seconds frameDur := float32(frame.Delay) / 1000 // convert to seconds
frameDescFile.WriteString(fmt.Sprintf("file '%s'\n", frame.File)) fmt.Fprintf(frameDescFile, "file '%s'\n", frame.File)
frameDescFile.WriteString(fmt.Sprintf("duration %f\n", frameDur)) fmt.Fprintf(frameDescFile, "duration %f\n", frameDur)
} }
// repeat last frame (see: https://trac.ffmpeg.org/wiki/Slideshow#Concatdemuxer // repeat last frame (see: https://trac.ffmpeg.org/wiki/Slideshow#Concatdemuxer
lastFrame := frames[len(frames)-1] lastFrame := frames[len(frames)-1]
frameDescFile.WriteString(fmt.Sprintf("file '%s'\n", lastFrame.File)) fmt.Fprintf(frameDescFile, "file '%s'\n", lastFrame.File)
} }
func callFFmpeg(frameDescPath, outputFilePath, workDir, ffmpegArgs string) error { func callFFmpeg(frameDescPath, outputFilePath, workDir, ffmpegArgs string) error {