Skip to content

Commit

Permalink
Fix issue with FFmpeg version with no pacth version
Browse files Browse the repository at this point in the history
FFmpeg uses MAYOR.MINOR.PATCH version semantics. When patch version is
0, the reported version is only MAYOR.MINOR.

For instace, when
```
$ ffmpeg -version
ffmpeg version n7.1 Copyright (c) 2000-2024 the FFmpeg developers
```

Error:
```
Traceback (most recent call last):
  File "/home/rgonzalez/src/github.com/fluendo/fluster/./fluster.py", line 23, in <module>
    fluster_main()
  File "/home/rgonzalez/src/github.com/fluendo/fluster/fluster/main.py", line 41, in fluster_main
    main.run()
  File "/home/rgonzalez/src/github.com/fluendo/fluster/fluster/main.py", line 85, in run
    args.func(args, fluster)
  File "/home/rgonzalez/src/github.com/fluendo/fluster/fluster/main.py", line 371, in _list_cmd
    fluster.list_decoders(check=args.check, verbose=args.verbose)
  File "/home/rgonzalez/src/github.com/fluendo/fluster/fluster/fluster.py", line 204, in list_decoders
    if decoder.check(verbose)
       ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rgonzalez/src/github.com/fluendo/fluster/fluster/decoders/ffmpeg.py", line 158, in check
    self.ffmpeg_version = tuple(map(int, version.groups())) if version else None
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
  • Loading branch information
rgonzalezfluendo committed Nov 21, 2024
1 parent 9df71d7 commit 5edeab2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fluster/decoders/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ def check(self, verbose: bool) -> bool:
# Get ffmpeg version
output = _run_ffmpeg_command(self.binary, "-version", verbose=verbose)
version = re.search(r" version n?(\d+)\.(\d+)(?:\.(\d+))?", output)
self.ffmpeg_version = tuple(map(int, version.groups())) if version else None
self.ffmpeg_version = (
tuple(map(lambda x: int(x) if x else 0, version.groups()))
if version
else None
)

# Check if codec can be used
output = _run_ffmpeg_command(self.binary, "-codecs", verbose=verbose)
Expand Down

0 comments on commit 5edeab2

Please sign in to comment.