ffmpy!
Browse files- .gitattributes +1 -0
- ejemploffmpy.py +6 -0
- funciones/__pycache__/motion.cpython-311.pyc +0 -0
- funciones/motion.py +50 -1
- output.avi +3 -0
- requirements.txt +2 -1
.gitattributes
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
2 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
1 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
2 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.avi filter=lfs diff=lfs merge=lfs -text
|
ejemploffmpy.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ffmpy import FFmpeg
|
2 |
+
ff = FFmpeg(
|
3 |
+
inputs={'input.mp4': None},
|
4 |
+
outputs={'output.avi': None}
|
5 |
+
)
|
6 |
+
ff.run()
|
funciones/__pycache__/motion.cpython-311.pyc
CHANGED
Binary files a/funciones/__pycache__/motion.cpython-311.pyc and b/funciones/__pycache__/motion.cpython-311.pyc differ
|
|
funciones/motion.py
CHANGED
@@ -2,7 +2,7 @@ import time
|
|
2 |
import subprocess
|
3 |
import herramientas
|
4 |
import random
|
5 |
-
|
6 |
|
7 |
async def motion(imagen):
|
8 |
|
@@ -11,6 +11,55 @@ async def motion(imagen):
|
|
11 |
|
12 |
print("Esto es imagen en monomotion: ", imagen)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
#ffmpeg_path = "/usr/bin/ffmpeg"
|
15 |
|
16 |
ffmpeg_command = [
|
|
|
2 |
import subprocess
|
3 |
import herramientas
|
4 |
import random
|
5 |
+
from ffmpy import FFmpeg
|
6 |
|
7 |
async def motion(imagen):
|
8 |
|
|
|
11 |
|
12 |
print("Esto es imagen en monomotion: ", imagen)
|
13 |
|
14 |
+
video_filters = (
|
15 |
+
f"scale=1280:720:force_original_aspect_ratio=increase,"
|
16 |
+
f"crop=1280:720,"
|
17 |
+
f"zoompan=z='zoom+0.0005':d=1500"
|
18 |
+
)
|
19 |
+
|
20 |
+
inputs = {
|
21 |
+
imagen: ['-loop', '1'] # -loop 1 es una opción para la entrada
|
22 |
+
}
|
23 |
+
|
24 |
+
outputs = {
|
25 |
+
f'resultados/{current_timestamp_int}.mp4': [
|
26 |
+
'-t', str(3), # Duración del video
|
27 |
+
'-vf', video_filters, # Tus filtros de video complejos
|
28 |
+
'-r', str(25), # Velocidad de fotogramas
|
29 |
+
'-pix_fmt', 'yuv420p', # Formato de píxeles
|
30 |
+
'-c:v', 'libx264', # Códec de video
|
31 |
+
'-preset', 'fast', # Preset de codificación
|
32 |
+
'-movflags', '+faststart', # Optimización MOOV atom
|
33 |
+
'-y' # Sobrescribir sin preguntar
|
34 |
+
]
|
35 |
+
}
|
36 |
+
|
37 |
+
# Instancia FFmpeg
|
38 |
+
ff = FFmpeg(inputs=inputs, outputs=outputs)
|
39 |
+
|
40 |
+
# Imprime el comando que ffmpy va a ejecutar (para depuración)
|
41 |
+
print("Comando ffmpy generado:")
|
42 |
+
print(ff.cmd)
|
43 |
+
|
44 |
+
# Ejecuta el comando
|
45 |
+
try:
|
46 |
+
ff.run()
|
47 |
+
print(f"Video creado exitosamente: resultados/{current_timestamp_int}.mp4")
|
48 |
+
except Exception as e:
|
49 |
+
print(f"Error al crear el video: {e}")
|
50 |
+
# ffmpy captura la salida estándar y de error, puedes acceder a ellas si necesitas depurar más a fondo:
|
51 |
+
# print(f"Salida de FFmpeg:\n{e.args[0]}")
|
52 |
+
# print(f"Error de FFmpeg:\n{e.args[1]}")
|
53 |
+
|
54 |
+
return f'resultados/{current_timestamp_int}.mp4'
|
55 |
+
|
56 |
+
async def motion_old(imagen):
|
57 |
+
|
58 |
+
current_timestamp_int = int(time.time())
|
59 |
+
print("Ésto es current time stamp: ", current_timestamp_int)
|
60 |
+
|
61 |
+
print("Esto es imagen en monomotion: ", imagen)
|
62 |
+
|
63 |
#ffmpeg_path = "/usr/bin/ffmpeg"
|
64 |
|
65 |
ffmpeg_command = [
|
output.avi
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a5b97f325c2428f8798f385af0ffc1687feebf428dc1a02cc50325fcf6c4eff9
|
3 |
+
size 1385088
|
requirements.txt
CHANGED
@@ -9,4 +9,5 @@
|
|
9 |
google-api-python-client
|
10 |
fastapi
|
11 |
uvicorn
|
12 |
-
python-multipart
|
|
|
|
9 |
google-api-python-client
|
10 |
fastapi
|
11 |
uvicorn
|
12 |
+
python-multipart
|
13 |
+
ffmpy
|