Created
February 8, 2026 12:20
-
-
Save eros18123/f325dc01b4238f8239a670f9f5a8c011 to your computer and use it in GitHub Desktop.
conversor mp4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import tkinter as tk | |
| from tkinter import filedialog | |
| # Tenta importar da maneira antiga (v1) ou nova (v2) para garantir que funcione | |
| try: | |
| from moviepy.editor import VideoFileClip | |
| except ImportError: | |
| try: | |
| from moviepy import VideoFileClip | |
| except ImportError: | |
| print("Erro crítico: A biblioteca moviepy não está instalada corretamente.") | |
| input("Pressione Enter para sair...") | |
| sys.exit() | |
| def selecionar_arquivo(): | |
| root = tk.Tk() | |
| root.withdraw() | |
| caminho_arquivo = filedialog.askopenfilename( | |
| title="Selecione o vídeo para converter", | |
| filetypes=[("Arquivos de Vídeo", "*.*")] | |
| ) | |
| return caminho_arquivo | |
| def converter_para_mp4(input_path): | |
| try: | |
| if not os.path.exists(input_path): | |
| print("Erro: Arquivo não encontrado.") | |
| return | |
| filename, _ = os.path.splitext(input_path) | |
| output_path = filename + "_convertido.mp4" | |
| print(f"\n--- Iniciando Conversão ---") | |
| print(f"Entrada: {input_path}") | |
| print(f"Saída: {output_path}") | |
| print("Processando... (Aguarde)") | |
| # Carrega o vídeo | |
| clip = VideoFileClip(input_path) | |
| # Escreve o arquivo | |
| clip.write_videofile( | |
| output_path, | |
| codec='libx264', | |
| audio_codec='aac', | |
| temp_audiofile='temp-audio.m4a', | |
| remove_temp=True, | |
| preset='medium' | |
| ) | |
| clip.close() | |
| print(f"\nSucesso! Vídeo salvo em: {output_path}") | |
| except Exception as e: | |
| print(f"\nOcorreu um erro: {e}") | |
| if __name__ == "__main__": | |
| print("Selecione o arquivo na janela que irá abrir...") | |
| arquivo_origem = selecionar_arquivo() | |
| if arquivo_origem: | |
| converter_para_mp4(arquivo_origem) | |
| else: | |
| print("Nenhum arquivo selecionado.") | |
| input("\nPressione Enter para sair...") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#instalar libs
pip install moviepy
py -m pip install moviepy
py -m pip install moviepy imageio-ffmpeg