mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
75b51808e2
* Add implementation + tests * Add comments' * Add warning * Update docs * Refactor logic * 3.7 fix attempt * Fix 3.7 take 2 * Return original video if the conversion fails * Use ffmprobe + restrict scope of exception * Fix for windows * Fix tests
22 lines
601 B
Python
22 lines
601 B
Python
import cv2
|
|
import gradio as gr
|
|
import numpy as np
|
|
|
|
|
|
def gif_maker():
|
|
img_array = []
|
|
height, width = 50, 50
|
|
for i in range(30):
|
|
img_array.append(np.random.randint(0, 255, size=(height, width, 3)).astype(np.uint8))
|
|
output_file = "test.mp4"
|
|
out = cv2.VideoWriter(output_file, cv2.VideoWriter_fourcc(*'mp4v'), 15, (height, width))
|
|
for i in range(len(img_array)):
|
|
out.write(img_array[i])
|
|
out.release()
|
|
return output_file, output_file
|
|
|
|
|
|
demo = gr.Interface(gif_maker, inputs=None, outputs=[gr.Video(), gr.File()])
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |