mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-22 08:34:32 +01:00
Including feature to increase or decrease media (volume) audio level
This commit is contained in:
parent
3318832e9d
commit
1a27022a63
@ -168,6 +168,9 @@ 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 +224,7 @@ def _real_main(argv=None):
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': opts.audioformat,
|
||||
'preferredquality': opts.audioquality,
|
||||
'preferredvolume': opts.audiovolume,
|
||||
'nopostoverwrites': opts.nopostoverwrites,
|
||||
})
|
||||
if opts.recodevideo:
|
||||
|
@ -701,6 +701,10 @@ 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='VOLUME',
|
||||
dest='audiovolume',
|
||||
help='Specify ffmpeg/avconv audio volume, insert a value in dB to increase audio volume')
|
||||
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,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']
|
||||
if self._preferredcodec == 'aac':
|
||||
more_opts += ['-f', 'adts']
|
||||
if self._preferredcodec == 'm4a':
|
||||
|
Loading…
Reference in New Issue
Block a user