Fix ffmpeg version detection

Fixes issue where ffmpeg version could not be detected if the version number had no patch number.
This commit is contained in:
WithoutPants 2024-05-10 16:36:08 +10:00
parent c5fef3977e
commit 77ee620877
1 changed files with 8 additions and 2 deletions

View File

@ -109,7 +109,7 @@ func (f *FFMpeg) getVersion() error {
return err
}
version_re := regexp.MustCompile(`ffmpeg version ((\d+)\.(\d+)\.(\d+))`)
version_re := regexp.MustCompile(`ffmpeg version ((\d+)\.(\d+)(?:\.(\d+))?)`)
stdoutStr := stdout.String()
match := version_re.FindStringSubmatchIndex(stdoutStr)
if match == nil {
@ -118,7 +118,13 @@ func (f *FFMpeg) getVersion() error {
majorS := stdoutStr[match[4]:match[5]]
minorS := stdoutStr[match[6]:match[7]]
patchS := stdoutStr[match[8]:match[9]]
// patch is optional
var patchS string
if match[8] != -1 && match[9] != -1 {
patchS = stdoutStr[match[8]:match[9]]
}
if i, err := strconv.Atoi(majorS); err == nil {
f.version.major = i
}