显示视频播放器。
函数签名
st.video(data, format="video/mp4", start_time=0)
参数 | 说明 |
---|---|
data (str, bytes, BytesIO, numpy.ndarray, or file opened with) | io.open()。指向要加载的视频的原始视频数据、文件名或 URL。包括对YouTube URL 的支持。 Numpy 数组和原始数据格式必须包含所有必要的文件头以匹配指定的文件格式。 |
format (str) | 视频文件的 MIME 类型。默认为'video/mp4'。有关详细信息,请参阅https://tools.ietf.org/html/rfc4281。 |
start_time (int) | 该元素应该开始播放的时间。 |
示例
video_file = open('myvideo.mp4', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
注意
如果使用 MP4V(OpenCV 中的导出选项)对某些视频进行编码,则某些视频可能无法显示,因为浏览器并未广泛支持此编解码器。将您的视频转换为 H.264 将允许视频在 Streamlit 中显示。有关详细信息,请参阅此 StackOverflow post 或此 Streamlit forum post。
相关用法
- Python Streamlit st.vega_lite_chart用法及代码示例
- Python Streamlit st.experimental_singleton.clear用法及代码示例
- Python Streamlit st.bokeh_chart用法及代码示例
- Python Streamlit st.caption用法及代码示例
- Python Streamlit st.text_input用法及代码示例
- Python Streamlit st.area_chart用法及代码示例
- Python Streamlit st.title用法及代码示例
- Python Streamlit st.cache用法及代码示例
- Python Streamlit st.experimental_singleton用法及代码示例
- Python Streamlit st.empty用法及代码示例
- Python Streamlit st.error用法及代码示例
- Python Streamlit st.slider用法及代码示例
- Python Streamlit st.header用法及代码示例
- Python Streamlit st.container用法及代码示例
- Python Streamlit st.form_submit_button用法及代码示例
- Python Streamlit st.form用法及代码示例
- Python Streamlit st.plotly_chart用法及代码示例
- Python Streamlit st.bar_chart用法及代码示例
- Python Streamlit st.code用法及代码示例
- Python Streamlit st.experimental_memo.clear用法及代码示例
- Python Streamlit st.warning用法及代码示例
- Python Streamlit st.image用法及代码示例
- Python Streamlit st.markdown用法及代码示例
- Python Streamlit st.expander用法及代码示例
- Python Streamlit st.experimental_memo用法及代码示例
注:本文由纯净天空筛选整理自streamlit.io大神的英文原创作品 st.video。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。