Created
June 19, 2024 11:58
-
-
Save heldonjose/03ee71179496cdcac756428b9a8072ec to your computer and use it in GitHub Desktop.
Cortar Vídeo tempo inicial e final
This file contains 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
from moviepy.video.io.VideoFileClip import VideoFileClip | |
def cortar_video(input_video_path, output_video_path, start_time, end_time): | |
# Carregar o vídeo | |
video = VideoFileClip(input_video_path) | |
# Cortar o vídeo entre os tempos especificados | |
video_cortado = video.subclip(start_time, end_time) | |
# Salvar o vídeo cortado | |
video_cortado.write_videofile(output_video_path, codec='libx264', audio_codec='aac') | |
# Exemplo de uso | |
input_video_path = "localvideo/video.mp4" | |
output_video_path = "localvideo/video_cortado.mp4" | |
start_time = "04:27:00" # Tempo de início no formato hh:mm:ss | |
end_time = "04:34:40" # Tempo de fim no formato hh:mm:ss | |
cortar_video(input_video_path, output_video_path, start_time, end_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment