Including feature to increase or decrease media (volume) audio level
This commit is contained in:
parent
40cf7fcbd2
commit
bed282f939
@ -361,6 +361,9 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
a value between 0 (better) and 9 (worse)
|
||||
for VBR or a specific bitrate like 128K
|
||||
(default 5)
|
||||
--audio-volume VOLUME Specify ffmpeg/avconv audio volume, insert
|
||||
a value in dB to increase audio volume.
|
||||
(default 4)
|
||||
--recode-video FORMAT Encode the video to another format if
|
||||
necessary (currently supported:
|
||||
mp4|flv|ogg|webm|mkv|avi)
|
||||
|
@ -168,6 +168,11 @@ def _real_main(argv=None):
|
||||
opts.audioquality = opts.audioquality.strip('k').strip('K')
|
||||
if not opts.audioquality.isdigit():
|
||||
parser.error('invalid audio quality specified')
|
||||
|
||||
if opts.audiovolume:
|
||||
if not opts.audioquality.isdigit():
|
||||
parser.error('invalid audio volume specified')
|
||||
|
||||
if opts.recodevideo is not None:
|
||||
if opts.recodevideo not in ['mp4', 'flv', 'webm', 'ogg', 'mkv', 'avi']:
|
||||
parser.error('invalid video recode format specified')
|
||||
@ -221,6 +226,7 @@ def _real_main(argv=None):
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': opts.audioformat,
|
||||
'preferredquality': opts.audioquality,
|
||||
'preferredvolume': opts.audiovolume,
|
||||
'nopostoverwrites': opts.nopostoverwrites,
|
||||
})
|
||||
if opts.recodevideo:
|
||||
@ -377,7 +383,7 @@ def _real_main(argv=None):
|
||||
with YoutubeDL(ydl_opts) as ydl:
|
||||
# Update version
|
||||
if opts.update_self:
|
||||
update_self(ydl.to_screen, opts.verbose, ydl._opener)
|
||||
update_self(ydl.to_screen, opts.verbose)
|
||||
|
||||
# Remove cache dir
|
||||
if opts.rm_cachedir:
|
||||
|
@ -688,6 +688,12 @@ def parseOpts(overrideArguments=None):
|
||||
'--audio-quality', metavar='QUALITY',
|
||||
dest='audioquality', default='5',
|
||||
help='Specify ffmpeg/avconv audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)')
|
||||
|
||||
postproc.add_option(
|
||||
'--audio-volume', metavar='QUALITY',
|
||||
dest='audiovolume', default=None,
|
||||
help='Specify ffmpeg/avconv audio volume, insert a value in dB to increase audio volume (default %default)')
|
||||
|
||||
postproc.add_option(
|
||||
'--recode-video',
|
||||
metavar='FORMAT', dest='recodevideo', default=None,
|
||||
|
@ -166,12 +166,13 @@ class FFmpegPostProcessor(PostProcessor):
|
||||
|
||||
|
||||
class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
|
||||
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, preferredvolume=None, nopostoverwrites=False):
|
||||
FFmpegPostProcessor.__init__(self, downloader)
|
||||
if preferredcodec is None:
|
||||
preferredcodec = 'best'
|
||||
self._preferredcodec = preferredcodec
|
||||
self._preferredquality = preferredquality
|
||||
self._preferredvolume = preferredvolume
|
||||
self._nopostoverwrites = nopostoverwrites
|
||||
|
||||
def get_audio_codec(self, path):
|
||||
@ -242,6 +243,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
more_opts += ['-q:a', self._preferredquality]
|
||||
else:
|
||||
more_opts += ['-b:a', self._preferredquality + 'k']
|
||||
if self._preferredvolume is not None:
|
||||
more_opts += ['-af', 'volume=volume='+self._preferredvolume+'dB:precision=fixed']
|
||||
else:
|
||||
# We convert the audio (lossy)
|
||||
acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'opus': 'opus', 'vorbis': 'libvorbis', 'wav': None}[self._preferredcodec]
|
||||
@ -253,6 +256,10 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
more_opts += ['-q:a', self._preferredquality]
|
||||
else:
|
||||
more_opts += ['-b:a', self._preferredquality + 'k']
|
||||
|
||||
if self._preferredvolume is not None:
|
||||
more_opts += ['-af', 'volume=volume='+self._preferredvolume+'dB:precision=fixed']
|
||||
|
||||
if self._preferredcodec == 'aac':
|
||||
more_opts += ['-f', 'adts']
|
||||
if self._preferredcodec == 'm4a':
|
||||
|
Loading…
x
Reference in New Issue
Block a user