VideoDubber / audioex.py
Suparnpreet's picture
Update audioex.py
8b73986 verified
raw
history blame
1.03 kB
import subprocess
import os
import shutil
def ex():
print("Started ex")
video_directory = os.getcwd()
video_files = [f for f in os.listdir(video_directory) if f.endswith(".mp4")]
for mp4_file in video_files:
# Full path to the mp4 file
mp4_file_path = os.path.join(video_directory, mp4_file)
print(mp4_file_path)
os.rename(mp4_file_path, "video.mp4")
print("Command started")
result = subprocess.run("sudo apt install ffmpeg", capture_output=True, text=True, check=True)
print("Command Output of ffmpeg:\n", result.stdout)
command2mp3 = "ffmpeg -i video.mp4 speech.mp3"
result1 = subprocess.run(command2mp3, capture_output=True, text=True, check=True)
print("Command Output of mp3:\n", result1.stdout)
command2wav = "ffmpeg -i speech.mp3 speech.wav"
result2 = subprocess.run(command2wav, capture_output=True, text=True, check=True)
print("Command Output of wav:\n", result2.stdout)
print("Command ended")