Skip to content

Instantly share code, notes, and snippets.

@97997
Created July 17, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 97997/7356ec3de28cd69a9d47789073ee09d7 to your computer and use it in GitHub Desktop.
Save 97997/7356ec3de28cd69a9d47789073ee09d7 to your computer and use it in GitHub Desktop.
#script takes working directory mp4 files (and others) (only tested with mp4) and uses ffmpeg to convert to variable bitrate mp3 files
#script takes working directory mp4 files (and others) (only tested with mp4) and uses ffmpeg to convert to variable bitrate mp3 files
workingDirectory = 'C:\\directory_with_the_mp4_files\\'
files = []
import os
for individualFile in os.listdir(workingDirectory):
totalpath = workingDirectory + individualFile
if individualFile.endswith(('.mp4', '.wmv', '.avi', '.mkv')):
files.append(totalpath)
for item in files:
os.system("ffmpeg -i \"" + item + "\" -q:a 0 -map a \"" + item.rsplit('.', 1)[0] + '\".mp3')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment