Skip to content

Commit

Permalink
[postprocessor/mkvtoolnix] WIP again
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesmiscore committed Dec 30, 2021
1 parent e521dd1 commit d7ea944
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions yt_dlp/postprocessor/mkvtoolnix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
encodeFilename,
Popen,
PostProcessingError,
prepend_extension,
shell_quote,
variadic,
)
Expand Down Expand Up @@ -134,3 +135,21 @@ def make_args(file, args, name, number):
if out_path:
self.try_utime(out_path, oldest_mtime, oldest_mtime)
return stderr


class MkvMergePostProcessor(MkvToolNixPostProcessor):

@PostProcessor._restrict_to(images=False)
def run(self, info):
filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp')
args = []
for (i, fmt) in enumerate(info['requested_formats']):
if fmt.get('acodec') != 'none':
args.extend(['--audio-tracks', '0'])
if fmt.get('vcodec') != 'none':
args.extend(['--video-tracks', '0'])
self.to_screen('Merging formats into "%s"' % filename)
self.run_binary(info['__files_to_merge'], temp_filename, args, info_dict=info)
self._downloader.rename(temp_filename, filename)
return info['__files_to_merge'], info

0 comments on commit d7ea944

Please sign in to comment.