Created
September 17, 2023 14:07
-
-
Save WillKirkmanM/8973422b9aebc4f9f6b40a63905f7b9f to your computer and use it in GitHub Desktop.
Metadata Preserving Audiobook Converter From .m4b -> .mp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import sys | |
cwd = os.getcwd() | |
files = os.listdir(cwd) | |
for file in files: | |
extension = os.path.splitext(file)[1] | |
if extension == '.m4b': | |
file_name = os.path.splitext(file)[0] | |
new_file_name = file_name + '.mp3' | |
command = 'ffmpeg -i "' + file + '" -c copy -map_metadata 0 -c:a libmp3lame -q:a 2 "' + new_file_name + '"' | |
subprocess.call(command, shell=True) | |
os.remove(file) | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment