miojizzy commited on
Commit
6e20ef2
·
1 Parent(s): 38c70a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -7
app.py CHANGED
@@ -1,14 +1,23 @@
1
  import os
 
2
  from zipfile import ZipFile
3
 
4
  import gradio as gr
5
 
6
 
7
- def zip_files(files):
8
- with ZipFile("tmp.zip", "w") as zipObj:
9
- for idx, file in enumerate(files):
10
- zipObj.write(file.name, file.name.split("/")[-1])
11
- return "tmp.zip"
 
 
 
 
 
 
 
 
12
 
13
  demo = gr.Interface(
14
  zip_files,
@@ -17,8 +26,18 @@ demo = gr.Interface(
17
  examples=[[[os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
18
  os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
19
  os.path.join(os.path.dirname(__file__),"files/titanic.csv")]]],
20
- cache_examples=True
21
  )
22
 
 
 
 
 
 
 
 
 
 
 
23
  if __name__ == "__main__":
24
- demo.launch()
 
1
  import os
2
+ import cv2 as cv
3
  from zipfile import ZipFile
4
 
5
  import gradio as gr
6
 
7
 
8
+ def get_video_info(v):
9
+ with cv.VideoCapture(v) as vc:
10
+ fps = vc.get(cv.CAP_PROP_FPS)
11
+ frames = vc.get(cv.CAP_PROP_FRAME_COUNT)
12
+ width = vc.get(cv.CAP_PROP_FRAME_WIDTH)
13
+ height = vc.get(cv.CAP_PROP_FRAME_HEIGHT)
14
+ return "\n".join([
15
+ "fps: " + fps,
16
+ "frame count: " + frames,
17
+ "width: " + width,
18
+ "height: " + height
19
+ ])
20
+
21
 
22
  demo = gr.Interface(
23
  zip_files,
 
26
  examples=[[[os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
27
  os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
28
  os.path.join(os.path.dirname(__file__),"files/titanic.csv")]]],
29
+ cache_examples=False
30
  )
31
 
32
+
33
+
34
+ with gr.Blocks() as demo:
35
+ with gr.Tab("get nth frame"):
36
+ input_video = gr.Video()
37
+ output_info = gr.Textbox(lines=4, label="info")
38
+ input_video.change(get_video_info, input=input_video, output=output_info)
39
+
40
+
41
+
42
  if __name__ == "__main__":
43
+ demo.queue().launch()