Skip to content

Comments

Hang-proof ffmpeg hardware codec checks#6414

Merged
WithoutPants merged 1 commit intostashapp:developfrom
WithoutPants:ffmpeg-hang-attempt-2
Dec 15, 2025
Merged

Hang-proof ffmpeg hardware codec checks#6414
WithoutPants merged 1 commit intostashapp:developfrom
WithoutPants:ffmpeg-hang-attempt-2

Conversation

@WithoutPants
Copy link
Collaborator

  • add WaitDelay to ffmpeg command to kill the process if it hangs
  • perform hardware codec tests in a separate goroutine so that ffmpeg initialisation can return immediately, hardware encoding will be disabled until the tests are completed
  • added warning log if initialisation takes more than 5 seconds

Related: https://discourse.stashapp.cc/t/initial-installation-hangs-on-optimizing-database/4739

I was unable to reproduce the hanging ffmpeg issue, even after installing ffmpeg 8.0.0 from chocolatey, so I created a hanging ffmpeg instance in go:

package main

import (
	"fmt"
	"os"
	"time"
)

func main() {

	if len(os.Args) > 1 && os.Args[1] == "-version" {
		fmt.Println("ffmpeg version 8.0-essentials_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers")
		os.Exit(0)
	}

	if len(os.Args) > 1 && os.Args[1] == "-h" {
		fmt.Println("--enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-libwebp")
		os.Exit(0)
	}

	time.Sleep(1 * time.Minute)
}

Warn if tests are taking a long time
Add WaitDelay to try to kill process if hanging
@WithoutPants WithoutPants added this to the Version 0.30.0 milestone Dec 15, 2025
@WithoutPants WithoutPants added the improvement Something needed tweaking. label Dec 15, 2025
@WithoutPants WithoutPants merged commit b23c3cd into stashapp:develop Dec 15, 2025
2 checks passed
@feederbox826
Copy link
Collaborator

Was about to PR a log message when hwinit tests start

@feederbox826

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Something needed tweaking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants