Skip to content

Instantly share code, notes, and snippets.

@elrond1999
Created June 29, 2012 18:04
Show Gist options
  • Save elrond1999/3019676 to your computer and use it in GitHub Desktop.
Save elrond1999/3019676 to your computer and use it in GitHub Desktop.
Python script to convert H264 MKV to MP4 with AAC without recoding. Very fast as the video is just copied. Requires FFMpeg in the same path as the script.
import sys
import time
import multiprocessing
import subprocess
import os.path
path = os.path.dirname(sys.argv[0])
def convert(arg):
global path
basename=os.path.splitext(os.path.basename(arg))
dest="g:\\Stuff\%s.mp4" % (basename[0])
cmd='%s\\ffmpeg.exe -i "%s" -f mp4 -vcodec copy -acodec libfaac -b:a 112k -ac 2 -y "%s"' % (path, arg, dest)
print cmd
return subprocess.call(cmd, shell=False)
if __name__ == '__main__':
#count = multiprocessing.cpu_count()
count = 4
pool = multiprocessing.Pool(processes=count)
print pool.map(convert, sys.arg
@elrond1999
Copy link
Author

Just drag and drop the mkv files you want to convert on to the script and they are converted in parallel.

@SBeausoleil
Copy link

I get an error when running from FFMPEG:

Unknown encoder 'libfaac'

@denis-trofimov
Copy link

Syntax error at #23 line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment