Skip to content

Commit

Permalink
replaygain: ffmpeg: check version
Browse files Browse the repository at this point in the history
Check if the libavfilter library supports replaygain calculation. Before version
6.67.100 that did require the `--enable-libebur128` compile-time-option, after
that the ebur128 library is included in libavfilter itself.

Thus we require either a recent enough libavfilter version or the
`--enable-libebur128` option.
  • Loading branch information
zsinskri committed Jun 27, 2019
1 parent c5fcf9d commit 779ded0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions beetsplug/replaygain.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,28 @@ def __init__(self, config, log):
self._ffmpeg_path = "ffmpeg"

# check that ffmpeg is installed
# TODO: check if ffmpeg version is sufficient
try:
call([self._ffmpeg_path, "-version"])
ffmpeg_version_out = call([self._ffmpeg_path, "-version"])
except OSError:
raise FatalReplayGainError(
u"could not find ffmpeg at {0}".format(self._ffmpeg_path)
)
incompatible_ffmpeg = True
for line in ffmpeg_version_out.stdout.splitlines():
if line.startswith(b"configuration:"):
if b"--enable-libebur128" in line:
incompatible_ffmpeg = False
if line.startswith(b"libavfilter"):
version = line.split(b" ", 1)[1].split(b"/", 1)[0].split(b".")
version = tuple(map(int, version))
if version >= (6, 67, 100):
incompatible_ffmpeg = False
if incompatible_ffmpeg:
raise FatalReplayGainError(
u"Installed FFmpeg version does not support ReplayGain."
u"calculation. Either libavfilter version 6.67.100 or above or"
u"the --enable-libebur128 configuration option is required."
)

# check that peak_method is valid
valid_peak_method = ("true", "sample")
Expand Down

0 comments on commit 779ded0

Please sign in to comment.