[FFmpegSubtitlesConvertorPP] remove intermediate srt files
[youtube-dl] / youtube_dl / postprocessor / ffmpeg.py
index d3d9d4f1da13be926b05714f04f801ce0f664613..6955b01f978c7e67b5330570971b1d0b423b8cf6 100644 (file)
@@ -392,7 +392,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
             options.extend(['-metadata', '%s=%s' % (name, value)])
 
         # https://github.com/rg3/youtube-dl/issues/8350
-        if info['protocol'] == 'm3u8_native':
+        if info.get('protocol') == 'm3u8_native' or info.get('protocol') == 'm3u8' and self._downloader.params.get('hls_prefer_native', False):
             options.extend(['-bsf:a', 'aac_adtstoasc'])
 
         self._downloader.to_screen('[ffmpeg] Adding metadata to \'%s\'' % filename)
@@ -508,6 +508,7 @@ class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
 
                 with io.open(srt_file, 'wt', encoding='utf-8') as f:
                     f.write(srt_data)
+                old_file = srt_file
 
                 ext = 'srt'
                 subs[lang] = {
@@ -517,12 +518,14 @@ class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
 
                 if new_ext == 'srt':
                     continue
+                else:
+                    sub_filenames.append(srt_file)
 
             self.run_ffmpeg(old_file, new_file, ['-f', new_format])
 
             with io.open(new_file, 'rt', encoding='utf-8') as f:
                 subs[lang] = {
-                    'ext': ext,
+                    'ext': new_ext,
                     'data': f.read(),
                 }