-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMp4ToWav.py
More file actions
23 lines (18 loc) · 858 Bytes
/
Mp4ToWav.py
File metadata and controls
23 lines (18 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import subprocess
# Loop through the filesystem
for root, dirs, files in os.walk("./folder", topdown=False):
# Loop through files
for name in files:
# Consider only mp4
if name.endswith('.mp4'):
# Using ffmpeg to convert the mp4 in wav
# Example command: "ffmpeg -i C:/test.mp4 -ab 160k -ac 2 -ar 44100 -vn audio.wav"
command = "ffmpeg -i /Users/marcogdepinto/Desktop" + root[1:] + "/" + name + " " + "-ab 160k -ac 2 -ar 44100 -vn /Users/marcogdepinto/Desktop/ConvertedFolder/" + name[:-3] + "wav"
#print(command)
# Execute conversion
try:
subprocess.call(command, shell=True)
# Skip the file in case of error
except ValueError:
continue