|
import time |
|
import subprocess |
|
import random |
|
from ffmpy import FFmpeg |
|
|
|
async def motion(imagen): |
|
|
|
current_timestamp_int = int(time.time()) |
|
print("Ésto es current time stamp: ", current_timestamp_int) |
|
|
|
print("Esto es imagen en monomotion: ", imagen) |
|
|
|
video_filters = ( |
|
f"scale=1280:720:force_original_aspect_ratio=increase," |
|
f"crop=1280:720," |
|
f"zoompan=z='zoom+0.0005':d=1500" |
|
) |
|
|
|
inputs = { |
|
imagen: ['-loop', '1'] |
|
} |
|
|
|
outputs = { |
|
f'{current_timestamp_int}.mp4': [ |
|
'-t', str(3), |
|
'-vf', video_filters, |
|
'-r', str(25), |
|
'-pix_fmt', 'yuv420p', |
|
'-c:v', 'libx264', |
|
'-preset', 'fast', |
|
'-movflags', '+faststart', |
|
'-y' |
|
] |
|
} |
|
|
|
|
|
ff = FFmpeg(inputs=inputs, outputs=outputs) |
|
|
|
|
|
print("Comando ffmpy generado:") |
|
print(ff.cmd) |
|
|
|
|
|
try: |
|
ff.run() |
|
print(f"Video creado exitosamente: resultados/{current_timestamp_int}.mp4") |
|
except Exception as e: |
|
print(f"Error al crear el video: {e}") |
|
|
|
print(f"Salida de FFmpeg:\n{e.args[0]}") |
|
print(f"Error de FFmpeg:\n{e.args[1]}") |
|
|
|
return f'{current_timestamp_int}.mp4' |
|
|
|
async def motion_old(imagen): |
|
|
|
current_timestamp_int = int(time.time()) |
|
print("Ésto es current time stamp: ", current_timestamp_int) |
|
|
|
print("Esto es imagen en monomotion: ", imagen) |
|
|
|
|
|
|
|
ffmpeg_command = [ |
|
'ffmpeg', '-y', |
|
|
|
'-loop', '1', |
|
'-i', |
|
f'{imagen}', |
|
'-t', str(3), |
|
'-vf', |
|
f"scale=1280:720:force_original_aspect_ratio=increase," |
|
f"crop=1280:720," |
|
f"zoompan=z='zoom+0.0005':d=1500", |
|
'-r', str(25), |
|
'-pix_fmt', 'yuv420p', |
|
'-c:v', 'libx264', |
|
'-preset', 'fast', |
|
'-movflags', '+faststart', |
|
f'resultados/{current_timestamp_int}.mp4' |
|
] |
|
|
|
print("Comando:") |
|
print(ffmpeg_command) |
|
|
|
subprocess.run(ffmpeg_command, check=True) |
|
|
|
return f'resultados/{current_timestamp_int}.mp4' |
|
|
|
async def cinema(lista): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return random.choice(lista) |