Closed gabrielbdornas closed 3 months ago
Resposta stackoverflow utilizada para montar primeira parte do script - corte do vídeo em si:
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
ffmpeg_extract_subclip("video1.mp4", t1, t2, targetname="test.mp4")
Resposta chatGP para converter hora em segundos:
Yes, you can use the datetime
module in Python to achieve this. Here is how you can convert a time string in the format "HH:MM:SS" into seconds using the datetime
module:
from datetime import datetime, timedelta
def time_to_seconds(time_str):
time_obj = datetime.strptime(time_str, '%H:%M:%S')
delta = timedelta(hours=time_obj.hour, minutes=time_obj.minute, seconds=time_obj.second)
return delta.total_seconds()
# Example usage
time_str = "02:30:00"
seconds = time_to_seconds(time_str)
print(int(seconds))
This script uses datetime.strptime
to parse the time string into a datetime
object. It then creates a timedelta
object from the hours, minutes, and seconds of the datetime
object, and finally, it returns the total number of seconds using the total_seconds
method. For the example "02:30:00", it will return 9000 seconds.
See #176 See https://github.com/automatiza-mg/handbook/issues/176#issue-2406236461