breadlicker45 commited on
Commit
5b1d8f6
·
1 Parent(s): a22e49b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -72
app.py CHANGED
@@ -1,73 +1,4 @@
1
-
2
-
3
- import os
4
  import streamlit as st
5
-
6
- # These are the formats supported in Streamlit right now.
7
- VIDEO_EXTENSIONS = ["mp4", "ogv", "m4v", "webm"]
8
-
9
- # For sample video files, try the Internet Archive, or download a few samples here:
10
- # http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5
11
-
12
-
13
- st.title("Video Player")
14
-
15
- st.header("Local video files")
16
- st.write(
17
- "You can use st.video to play a locally-stored video by supplying it with a valid filesystem path."
18
- )
19
-
20
-
21
- def get_video_files_in_dir(directory):
22
- out = []
23
- for item in os.listdir(directory):
24
- try:
25
- name, ext = item.split(".")
26
- except:
27
- continue
28
- if name and ext:
29
- if ext in VIDEO_EXTENSIONS:
30
- out.append(item)
31
- return out
32
-
33
-
34
- avdir = os.path.expanduser("~")
35
- files = get_video_files_in_dir(avdir)
36
-
37
- if len(files) == 0:
38
- st.write(
39
- "Put some video files in your home directory (%s) to activate this player."
40
- % avdir
41
- )
42
-
43
- else:
44
- filename = st.selectbox(
45
- "Select a video file from your home directory (%s) to play" % avdir,
46
- files,
47
- 0,
48
- )
49
-
50
- st.video(os.path.join(avdir, filename))
51
- st.header("Remote video playback")
52
- st.write("st.video allows a variety of HTML5 supported video links, including YouTube.")
53
-
54
-
55
- def shorten_vid_option(opt):
56
- return opt.split("/")[-1]
57
-
58
-
59
- # A random sampling of videos found around the web. We should replace
60
- # these with those sourced from the streamlit community if possible!
61
- vidurl = st.selectbox(
62
- "Pick a video to play",
63
- (
64
- "http://tree2.rf.gd/uploads/apple.mp4",
65
- "https://youtu.be/FtutLA63Cp8",
66
- "https://youtu.be/FtutLA63Cp8"
67
-
68
- ),
69
- 0,
70
- shorten_vid_option,
71
- )
72
-
73
- st.video(vidurl)
 
 
 
 
1
  import streamlit as st
2
+ video_file = open('apple.mp4', 'rb')
3
+ video_bytes = video_file.read()
4
+ st.video(video_bytes)