diff --git a/.gitignore b/.gitignore index 2937445bf..79d1dfeb3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ vendor/ config/config.yaml config/stats.json owncast -webroot/thumbnail.png +webroot/thumbnail.jpg webroot/hls webroot/static/content.md hls/ \ No newline at end of file diff --git a/ffmpeg.go b/ffmpeg.go index 3fff1a344..8e8d24e36 100644 --- a/ffmpeg.go +++ b/ffmpeg.go @@ -51,7 +51,7 @@ func showStreamOfflineState(configuration Config) { // "-stream_loop 100", // "-fflags", "+genpts", "-i", configuration.VideoSettings.OfflineImage, - "-i", "webroot/thumbnail.png", + "-i", "webroot/thumbnail.jpg", "-filter_complex", "\"[0:v]scale=2640:2360[bg];[bg][1:v]overlay=200:250:enable='between(t,0,3)'\"", videoMapsString, // All the different video variants "-f hls", diff --git a/scripts/build.sh b/scripts/build.sh index 631a62ab0..3df1859f5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -21,7 +21,7 @@ GIT_COMMIT=$(git rev-list -1 HEAD) cd $(git rev-parse --show-toplevel) echo "Cleaning working directories..." -rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.png +rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.jpg echo "Creating version ${VERSION} from commit ${GIT_COMMIT}" diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 000000000..24acf3e00 Binary files /dev/null and b/static/logo.png differ diff --git a/thumbnailGenerator.go b/thumbnailGenerator.go index 3de76b3bf..f81bd6afe 100644 --- a/thumbnailGenerator.go +++ b/thumbnailGenerator.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path" + "strings" "time" ) @@ -30,7 +31,9 @@ func startThumbnailGenerator(chunkPath string) { func fireThumbnailGenerator(chunkPath string) { framePath := path.Join(chunkPath, "0") files, err := ioutil.ReadDir(framePath) - outputFile := path.Join("webroot", "thumbnail.png") + + // JPG takes less time to encode than PNG + outputFile := path.Join("webroot", "thumbnail.jpg") // fmt.Println("Generating thumbnail from", framePath, "to", outputFile) @@ -63,7 +66,18 @@ func fireThumbnailGenerator(chunkPath string) { mostRecentFile := path.Join(framePath, names[0]) - ffmpegCmd := "ffmpeg -y -i " + mostRecentFile + " -ss 00:00:01.000 -vframes 1 " + outputFile + thumbnailCmdFlags := []string{ + configuration.FFMpegPath, + "-y", // Overwrite file + "-threads 1", // Low priority processing + "-t 1", // Pull from frame 1 + "-i", mostRecentFile, // Input + "-f image2", // format + "-vframes 1", // Single frame + outputFile, + } + + ffmpegCmd := strings.Join(thumbnailCmdFlags, " ") // fmt.Println(ffmpegCmd) diff --git a/utils.go b/utils.go index 36c84ee91..8a333f220 100644 --- a/utils.go +++ b/utils.go @@ -78,10 +78,10 @@ func resetDirectories(configuration Config) { func createInitialOfflineState() { // Provide default files - showStreamOfflineState(configuration) - if !fileExists("webroot/thumbnail.png") { - copy("static/logo.png", "webroot/thumbnail.png") + if !fileExists("webroot/thumbnail.jpg") { + copy("static/logo.png", "webroot/thumbnail.jpg") } + showStreamOfflineState(configuration) } func getClientIDFromRequest(req *http.Request) string { diff --git a/webroot/index.html b/webroot/index.html index 8ee8e010e..467c4f387 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -74,7 +74,7 @@ GW TODO: autoplay playsinline muted - poster="/thumbnail.png" + poster="/thumbnail.jpg" >