Skip to content

Commit

Permalink
Use mkvmerge first then fallback to ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
NoAiOne committed Jan 17, 2020
1 parent 45a5b81 commit ed0c561
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions yuu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ def mux_video(old_file):
It will try to use ffmpeg first, if it's not in the PATH, then it will try to use mkvmerge
If it's doesn't exist too, it just gonna skip.
"""
# FFMPEG check
# MkvMerge/FFMPEG check
use_ffmpeg = False
use_mkvmerge = False
try:
subprocess.check_call(['ffmpeg', '-version'])
use_ffmpeg = True
subprocess.check_call(['mkvmerge', '-V'])
use_mkvmerge = True
except FileNotFoundError:
try:
subprocess.check_call(['mkvmerge', '-V'])
use_mkvmerge = True
subprocess.check_call(['ffmpeg', '-version'])
use_ffmpeg = True
except FileNotFoundError:
return None

fn_, _ = os.path.splitext(old_file)
if use_ffmpeg:
subprocess.call(['ffmpeg', '-i', old_file, '-c', 'copy', '{f}.mkv'.format(f=fn_)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if use_mkvmerge:
subprocess.call(['mkvmerge', '-o', '{f}.mkv'.format(f=fn_), old_file], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if use_ffmpeg:
subprocess.call(['ffmpeg', '-i', old_file, '-c', 'copy', '{f}.mkv'.format(f=fn_)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
return '{f}.mkv'.format(f=fn_)


Expand Down

0 comments on commit ed0c561

Please sign in to comment.