Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from os import path
- from subprocess import run
- class VideoConverter:
- def __init__(self, input_directory: str, output_directory: str, output_format: str):
- self.input_directory = input_directory
- self.output_directory = output_directory
- self.output_format = output_format
- def convert_video(self, input_file: str):
- output_file = path.join(self.output_directory, path.basename(input_file))
- command = ["ffmpeg", "-i", input_file, "-c:v", self.output_format, "-c:a", "copy", output_file]
- run(command)
- def main():
- input_directory = "/path/to/input/videos"
- output_directory = "/path/to/output/videos"
- output_format = "mp4"
- video_converter = VideoConverter(input_directory, output_directory, output_format)
- for input_file in os.listdir(video_converter.input_directory):
- video_converter.convert_video(path.join(video_converter.input_directory, input_file))
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement