[ffmpeg] Detect libavformat version for aac_adtstoasc

and print available features in verbose head
Based on https://github.com/ytdl-org/youtube-dl/pull/29581
This commit is contained in:
pukkandan 2021-11-04 03:10:49 +05:30
parent 832e9000c7
commit 8913ef74d7
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
3 changed files with 15 additions and 4 deletions

View file

@ -3350,7 +3350,11 @@ def python_implementation():
platform.architecture()[0],
platform_name()))
exe_versions = FFmpegPostProcessor.get_versions(self)
exe_versions, ffmpeg_features = FFmpegPostProcessor.get_versions_and_features(self)
ffmpeg_features = {key for key, val in ffmpeg_features.items() if val}
if ffmpeg_features:
exe_versions['ffmpeg'] += f' (%s)' % ','.join(ffmpeg_features)
exe_versions['rtmpdump'] = rtmpdump_version()
exe_versions['phantomjs'] = PhantomJSwrapper._version()
exe_str = ', '.join(

View file

@ -21,7 +21,6 @@
encodeArgument,
handle_youtubedl_headers,
check_executable,
is_outdated_version,
Popen,
sanitize_open,
)
@ -459,7 +458,7 @@ def _call_downloader(self, tmpfilename, info_dict):
args += ['-f', 'mpegts']
else:
args += ['-f', 'mp4']
if (ffpp.basename == 'ffmpeg' and is_outdated_version(ffpp._versions['ffmpeg'], '3.2', False)) and (not info_dict.get('acodec') or info_dict['acodec'].split('.')[0] in ('aac', 'mp4a')):
if (ffpp.basename == 'ffmpeg' and ffpp._features.get('needs_adtstoasc')) and (not info_dict.get('acodec') or info_dict['acodec'].split('.')[0] in ('aac', 'mp4a')):
args += ['-bsf:a', 'aac_adtstoasc']
elif protocol == 'rtmp':
args += ['-f', 'flv']

View file

@ -75,9 +75,14 @@ def check_version(self):
self.basename, self.basename, required_version)
self.report_warning(warning)
@staticmethod
def get_versions_and_features(downloader=None):
pp = FFmpegPostProcessor(downloader)
return pp._versions, pp._features
@staticmethod
def get_versions(downloader=None):
return FFmpegPostProcessor(downloader)._versions
return FFmpegPostProcessor.get_version_and_features(downloader)[0]
def _determine_executables(self):
programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
@ -99,9 +104,12 @@ def get_ffmpeg_version(path, prog):
if prog != 'ffmpeg' or not out:
return
mobj = re.search(r'(?m)^\s+libavformat\s+(?:[0-9. ]+)\s+/\s+(?P<runtime>[0-9. ]+)', out)
lavf_runtime_version = mobj.group('runtime').replace(' ', '') if mobj else None
self._features = {
'fdk': '--enable-libfdk-aac' in out,
'setts': 'setts' in out.splitlines(),
'needs_adtstoasc': is_outdated_version(lavf_runtime_version, '57.56.100', False),
}
self.basename = None