forked from minhngoc25a/yt-dlc
m4a: aac in mp4 container (Closes #240)
This commit is contained in:
parent
94fd3201b2
commit
3e0ea7d07a
|
@ -3968,8 +3968,13 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
more_opts = []
|
more_opts = []
|
||||||
if self._preferredcodec == 'best' or self._preferredcodec == filecodec:
|
if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (self._preferredcodec == 'm4a' and filecodec == 'aac'):
|
||||||
if filecodec in ['aac', 'mp3', 'vorbis']:
|
if self._preferredcodec == 'm4a' and filecodec == 'aac':
|
||||||
|
# Lossless, but in another container
|
||||||
|
acodec = 'copy'
|
||||||
|
extension = self._preferredcodec
|
||||||
|
more_opts = ['-absf', 'aac_adtstoasc']
|
||||||
|
elif filecodec in ['aac', 'mp3', 'vorbis']:
|
||||||
# Lossless if possible
|
# Lossless if possible
|
||||||
acodec = 'copy'
|
acodec = 'copy'
|
||||||
extension = filecodec
|
extension = filecodec
|
||||||
|
@ -3986,13 +3991,15 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||||
more_opts += ['-ab', self._preferredquality]
|
more_opts += ['-ab', self._preferredquality]
|
||||||
else:
|
else:
|
||||||
# We convert the audio (lossy)
|
# We convert the audio (lossy)
|
||||||
acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'vorbis': 'libvorbis'}[self._preferredcodec]
|
acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'vorbis': 'libvorbis'}[self._preferredcodec]
|
||||||
extension = self._preferredcodec
|
extension = self._preferredcodec
|
||||||
more_opts = []
|
more_opts = []
|
||||||
if self._preferredquality is not None:
|
if self._preferredquality is not None:
|
||||||
more_opts += ['-ab', self._preferredquality]
|
more_opts += ['-ab', self._preferredquality]
|
||||||
if self._preferredcodec == 'aac':
|
if self._preferredcodec == 'aac':
|
||||||
more_opts += ['-f', 'adts']
|
more_opts += ['-f', 'adts']
|
||||||
|
if self._preferredcodec == 'm4a':
|
||||||
|
more_opts += ['-absf', 'aac_adtstoasc']
|
||||||
if self._preferredcodec == 'vorbis':
|
if self._preferredcodec == 'vorbis':
|
||||||
extension = 'ogg'
|
extension = 'ogg'
|
||||||
|
|
||||||
|
@ -4239,7 +4246,7 @@ def parseOpts():
|
||||||
postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
|
postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
|
||||||
help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
|
help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
|
||||||
postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
|
postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
|
||||||
help='"best", "aac", "vorbis" or "mp3"; best by default')
|
help='"best", "aac", "vorbis", "mp3", or "m4a"; best by default')
|
||||||
postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='128K',
|
postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='128K',
|
||||||
help='ffmpeg audio bitrate specification, 128k by default')
|
help='ffmpeg audio bitrate specification, 128k by default')
|
||||||
postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
|
postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
|
||||||
|
@ -4385,7 +4392,7 @@ def _real_main():
|
||||||
except (TypeError, ValueError), err:
|
except (TypeError, ValueError), err:
|
||||||
parser.error(u'invalid playlist end number specified')
|
parser.error(u'invalid playlist end number specified')
|
||||||
if opts.extractaudio:
|
if opts.extractaudio:
|
||||||
if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis']:
|
if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis', 'm4a']:
|
||||||
parser.error(u'invalid audio format specified')
|
parser.error(u'invalid audio format specified')
|
||||||
|
|
||||||
# File downloader
|
# File downloader
|
||||||
|
|
Loading…
Reference in New Issue