顯示視頻播放器。
函數簽名
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。