Add native support for Windows (#4491)

* Add support for Windows

* Fixes for Windows

* Update unit tests

* Fix ffreport setting

* Add test script equivalents

* Fix fontconfig error in test stream

* Fix thumbnail generator

* Fix lint warnings

* Fix warnings in test stream script

* Implement cross-platform ocTestStream

* Migrate to cross-platform script

* Revert ocTestStream.sh

* Add missing EOL

* Alternative test scripts for non-linux environments

---------

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Nicholas Kwan
2025-10-14 06:55:13 +08:00
committed by GitHub
parent f30b80d473
commit fd89c6e8f2
13 changed files with 590 additions and 169 deletions

View File

@ -5,7 +5,6 @@ import (
"os/exec"
"path"
"strconv"
"strings"
"time"
log "github.com/sirupsen/logrus"
@ -94,18 +93,16 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
outputFileTemp := path.Join(config.TempDir, "tempthumbnail.jpg")
thumbnailCmdFlags := []string{
ffmpegPath,
"-y", // Overwrite file
"-threads 1", // Low priority processing
"-t 1", // Pull from frame 1
"-y", // Overwrite file
"-threads", "1", // Low priority processing
"-t", "1", // Pull from frame 1
"-i", mostRecentFile, // Input
"-f image2", // format
"-vframes 1", // Single frame
"-f", "image2", // format
"-vframes", "1", // Single frame
outputFileTemp,
}
ffmpegCmd := strings.Join(thumbnailCmdFlags, " ")
if _, err := exec.Command("sh", "-c", ffmpegCmd).Output(); err != nil {
if _, err := exec.Command(ffmpegPath, thumbnailCmdFlags...).Output(); err != nil {
return err
}
@ -126,17 +123,15 @@ func makeAnimatedGifPreview(sourceFile string, outputFile string) {
// Filter is pulled from https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
animatedGifFlags := []string{
ffmpegPath,
"-y", // Overwrite file
"-threads 1", // Low priority processing
"-y", // Overwrite file
"-threads", "1", // Low priority processing
"-i", sourceFile, // Input
"-t 1", // Output is one second in length
"-filter_complex", "\"[0:v] fps=8,scale=w=480:h=-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=new=1\"",
"-t", "1", // Output is one second in length
"-filter_complex", "[0:v] fps=8,scale=w=480:h=-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=new=1",
outputFileTemp,
}
ffmpegCmd := strings.Join(animatedGifFlags, " ")
if _, err := exec.Command("sh", "-c", ffmpegCmd).Output(); err != nil {
if _, err := exec.Command(ffmpegPath, animatedGifFlags...).Output(); err != nil {
log.Errorln(err)
// rename temp file
} else if err := utils.Move(outputFileTemp, outputFile); err != nil {