Spaces:
Runtime error
Runtime error
| import subprocess | |
| import os | |
| import shutil | |
| def ex(): | |
| print("Started ex") | |
| video_directory = "video" | |
| video_files = [f for f in os.listdir(video_directory) if f.endswith(".mp4")] | |
| print(f"Founded Video Files is : {video_files}") | |
| 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") | |
| try: | |
| result = subprocess.run(["sudo", "apt", "install", "ffmpeg"], capture_output=True, text=True, check=True) | |
| print("FFmpeg installed successfully.") | |
| print("Command Output of ffmpeg:\n", result.stdout) | |
| except subprocess.CalledProcessError as e: | |
| print(f"Error installing FFmpeg: {e}") | |
| print(f"Return code: {e.returncode}") | |
| print(f"Output: {e.output}") | |
| command2mp3 = ["ffmpeg", "-i", "video.mp4", "speech.mp3"] | |
| result1 = subprocess.run(command2mp3, capture_output=True, text=True, check=True, shell=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, shell=True) | |
| print("Command Output of wav:\n", result2.stdout) | |
| print("Command ended") | |