mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 16:57:40 +00:00
FFmpegMetadataPP; Write temporary file to something.temp.{ext}
(fixes #2079)
ffmpeg correctly recognize the formats of extensions like m4a, but it doesn’t works if it’s passed with the `—format` option.
This commit is contained in:
parent
9887c9b2d6
commit
91d7d0b333
2 changed files with 7 additions and 3 deletions
|
@ -10,6 +10,7 @@ from .utils import (
|
||||||
PostProcessingError,
|
PostProcessingError,
|
||||||
shell_quote,
|
shell_quote,
|
||||||
subtitles_filename,
|
subtitles_filename,
|
||||||
|
prepend_extension,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -496,13 +497,11 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||||
return True, info
|
return True, info
|
||||||
|
|
||||||
filename = info['filepath']
|
filename = info['filepath']
|
||||||
ext = os.path.splitext(filename)[1][1:]
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
temp_filename = filename + u'.temp'
|
|
||||||
|
|
||||||
options = ['-c', 'copy']
|
options = ['-c', 'copy']
|
||||||
for (name, value) in metadata.items():
|
for (name, value) in metadata.items():
|
||||||
options.extend(['-metadata', '%s=%s' % (name, value)])
|
options.extend(['-metadata', '%s=%s' % (name, value)])
|
||||||
options.extend(['-f', ext])
|
|
||||||
|
|
||||||
self._downloader.to_screen(u'[ffmpeg] Adding metadata to \'%s\'' % filename)
|
self._downloader.to_screen(u'[ffmpeg] Adding metadata to \'%s\'' % filename)
|
||||||
self.run_ffmpeg(filename, temp_filename, options)
|
self.run_ffmpeg(filename, temp_filename, options)
|
||||||
|
|
|
@ -1119,3 +1119,8 @@ def parse_duration(s):
|
||||||
if m.group('hours'):
|
if m.group('hours'):
|
||||||
res += int(m.group('hours')) * 60 * 60
|
res += int(m.group('hours')) * 60 * 60
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def prepend_extension(filename, ext):
|
||||||
|
name, real_ext = os.path.splitext(filename)
|
||||||
|
return u'{0}.{1}{2}'.format(name, ext, real_ext)
|
||||||
|
|
Loading…
Reference in a new issue