Skip to content

Instantly share code, notes, and snippets.

@aceakash
Created September 17, 2017 17:13
Show Gist options
  • Save aceakash/38de61ba663509d8bfd60319b6c4fd7c to your computer and use it in GitHub Desktop.
Save aceakash/38de61ba663509d8bfd60319b6c4fd7c to your computer and use it in GitHub Desktop.
Convert audio in MKV files to AC3. Required Python 3.6
import os
import subprocess
all_dir_contents = os.listdir()
mkv_files = [file for file in all_dir_contents if file.endswith('.mkv') and not file.endswith('.converted.mkv') ]
for mkv in mkv_files:
print('========== Starting ' + mkv + ' ===========')
out_file_name = mkv[:-4] + '.converted.mkv'
subprocess.run(['ffmpeg', '-i', mkv, '-map', '0', '-vcodec', 'copy',
'-scodec', 'copy', '-acodec', 'ac3', '-b:a', '384k', out_file_name])
subprocess.run(['rm', mkv])
print('////////// Finished ' + mkv + ' ///////////')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment