Skip to content

Instantly share code, notes, and snippets.

@nate-moo
Last active September 30, 2021 22:55
Show Gist options
  • Save nate-moo/44853f3c08fb4949fe081bd2b1c74640 to your computer and use it in GitHub Desktop.
Save nate-moo/44853f3c08fb4949fe081bd2b1c74640 to your computer and use it in GitHub Desktop.
import subprocess
import sys
import re
var = str(subprocess.check_output(["mkvmerge.exe", "--identify", "video.mkv"]).decode(sys.stdout.encoding))
AttachmentID = re.findall(r"(Attachment ID (\d{1,2}):)", var)
AttachmentName = re.findall(r"(file name ('(.*)'))", var)
for a, b in zip(AttachmentID, AttachmentName):
funnymanjoe = subprocess.Popen(["mkvextract.exe", "video.mkv", "attachments", a[1] + ":" + b[2]])
print(a[1] + b[1])
@nate-moo
Copy link
Author

nate-moo commented Sep 30, 2021

Add python script to same directory as mkvtoolnix executables (or have them on path) and the video file named "video.mkv"

If on linux remove ".exe" from executable files

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