Skip to content

Commit

Permalink
convert sample_rate to integer and dont force a volume_filter
Browse files Browse the repository at this point in the history
added volume_filter example

deleted _get_volume_filter
  • Loading branch information
Death916 authored and eukreign committed Jul 15, 2020
1 parent 8c25f65 commit 7b01dde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ _trial_temp/
/tests/integration/blockchain/files
/tests/.coverage.*

/lbry/wallet/bin
/lbry/wallet/bin

/.vscode
/.gitignore
2 changes: 1 addition & 1 deletion lbry/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class TranscodeConfig(BaseConfig):
audio_encoder = String('FFmpeg codec and parameters for the audio encoding. '
'Example: libopus -b:a 128k',
'aac -b:a 160k')
volume_filter = String('FFmpeg filter for audio normalization.', '-af loudnorm')
volume_filter = String('FFmpeg filter for audio normalization. Exmple: -af loudnorm', '')
volume_analysis_time = Integer('Maximum seconds into the file that we examine audio volume (0 to disable).', 240)


Expand Down
11 changes: 3 additions & 8 deletions lbry/file_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,11 @@ def _verify_audio_encoding(scan_data: json):
if stream["codec_type"] != "audio":
continue
codec = stream["codec_name"]
sample_rate = stream['sample_rate']
log.debug(" Detected audio codec is %s", codec)
if not {"aac", "mp3", "flac", "vorbis", "opus"}.intersection(codec.split(",")):
return "Audio codec is not in the approved list of AAC, FLAC, MP3, Vorbis, and Opus. " \
f"Actual: {codec} [{stream['codec_long_name']}]"
if sample_rate > "48000":
if int(stream['sample_rate']) > 48000:
return "Sample rate out of range"

return ""
Expand Down Expand Up @@ -307,9 +306,6 @@ async def _get_audio_encoder(self, extension):

raise Exception(f"The audio encoder is not available. Requested: {encoder or 'aac'}")

async def _get_volume_filter(self):
return self._conf.volume_filter if self._conf.volume_filter else "-af loudnorm"

@staticmethod
def _get_best_container_extension(scan_data, video_encoder):
# the container is chosen by the video format
Expand Down Expand Up @@ -433,9 +429,8 @@ async def verify_or_repair(self, validate, repair, file_path, ignore_non_video=F
if audio_msg or volume_msg:
audio_encoder = await self._get_audio_encoder(extension)
transcode_command.append(audio_encoder)
if volume_msg:
volume_filter = await self._get_volume_filter()
transcode_command.append(volume_filter)
if volume_msg and self._conf.volume_filter:
transcode_command.append(self._conf.volume_filter)
if audio_msg == "Sample rate out of range":
transcode_command.append(" -ar 48000 ")
else:
Expand Down

0 comments on commit 7b01dde

Please sign in to comment.