Compare commits

..

No commits in common. "8c31540e3ab91da858cc0ca742f0e9e2117a0d9d" and "8297e51b34cebe71244cc27fd9dad4a82fffa1ab" have entirely different histories.

View File

@ -90,31 +90,16 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
success = True success = True
if info['ext'] == 'mp3': if info['ext'] == 'mp3':
# Method 1: Use mutagen # Using ffmpeg to embed the thumbnail in mp3 files is messing up lyrics
# Prioritize mutagen over ffmpeg since ffmpeg messes up the lyrics data # Using using mutagen instead
if mutagen: audio = mutagen.id3.ID3(filename)
try: if 'APIC' in audio:
self._report_run('mutagen', filename) del audio['APIC']
audio = mutagen.id3.ID3(filename) with open(thumbnail_filename, 'rb') as thumbfile:
if 'APIC' in audio: audio['APIC'] = mutagen.id3.APIC(
del audio['APIC'] encoding=3, mime='image/%s' % thumbnail_ext, type=3,
with open(thumbnail_filename, 'rb') as thumbfile: desc=u'Cover (front)', data=thumbfile.read())
audio['APIC'] = mutagen.id3.APIC( audio.save()
encoding=3, mime='image/%s' % thumbnail_ext, type=3,
desc=u'Cover (front)', data=thumbfile.read())
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())
@ -234,7 +219,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 success and temp_filename != filename: if info['ext'] != 'mp3' and 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)