mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 17:51:24 +01:00
Compare commits
2 Commits
8297e51b34
...
8c31540e3a
Author | SHA1 | Date | |
---|---|---|---|
|
8c31540e3a | ||
|
54605db1fa |
|
@ -90,8 +90,11 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
if info['ext'] == 'mp3':
|
if info['ext'] == 'mp3':
|
||||||
# Using ffmpeg to embed the thumbnail in mp3 files is messing up lyrics
|
# Method 1: Use mutagen
|
||||||
# Using using mutagen instead
|
# Prioritize mutagen over ffmpeg since ffmpeg messes up the lyrics data
|
||||||
|
if mutagen:
|
||||||
|
try:
|
||||||
|
self._report_run('mutagen', filename)
|
||||||
audio = mutagen.id3.ID3(filename)
|
audio = mutagen.id3.ID3(filename)
|
||||||
if 'APIC' in audio:
|
if 'APIC' in audio:
|
||||||
del audio['APIC']
|
del audio['APIC']
|
||||||
|
@ -100,6 +103,18 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||||
encoding=3, mime='image/%s' % thumbnail_ext, type=3,
|
encoding=3, mime='image/%s' % thumbnail_ext, type=3,
|
||||||
desc=u'Cover (front)', data=thumbfile.read())
|
desc=u'Cover (front)', data=thumbfile.read())
|
||||||
audio.save()
|
audio.save()
|
||||||
|
temp_filename = filename # Mutagen saves to the original file
|
||||||
|
except Exception as err:
|
||||||
|
self.report_warning('unable to embed using mutagen; %s' % error_to_compat_str(err))
|
||||||
|
success = False
|
||||||
|
# Method 2: Use ffmpeg
|
||||||
|
else:
|
||||||
|
options = [
|
||||||
|
'-c', 'copy', '-map', '0:0', '-map', '1:0', '-write_id3v1', '1', '-id3v2_version', '3',
|
||||||
|
'-metadata:s:v', 'title="Album cover"', '-metadata:s:v', 'comment=Cover (front)']
|
||||||
|
|
||||||
|
self._report_run('ffmpeg', filename)
|
||||||
|
self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
|
||||||
|
|
||||||
elif info['ext'] in ['mkv', 'mka']:
|
elif info['ext'] in ['mkv', 'mka']:
|
||||||
options = list(self.stream_copy_opts())
|
options = list(self.stream_copy_opts())
|
||||||
|
@ -219,7 +234,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||||
else:
|
else:
|
||||||
raise EmbedThumbnailPPError('Supported filetypes for thumbnail embedding are: mp3, mkv/mka, ogg/opus/flac, m4a/mp4/m4v/mov')
|
raise EmbedThumbnailPPError('Supported filetypes for thumbnail embedding are: mp3, mkv/mka, ogg/opus/flac, m4a/mp4/m4v/mov')
|
||||||
|
|
||||||
if info['ext'] != 'mp3' and success and temp_filename != filename:
|
if success and temp_filename != filename:
|
||||||
os.replace(temp_filename, filename)
|
os.replace(temp_filename, filename)
|
||||||
|
|
||||||
self.try_utime(filename, mtime, mtime)
|
self.try_utime(filename, mtime, mtime)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user