Streamlit App (
Код: Выделить всё
streamlitapp.py
Код: Выделить всё
import streamlit as st
import ffmpeg
import cv2
uploaded_file = st.file_uploader("Upload a video file", type="mp4")
if uploaded_file is not None:
# Save and convert video
with open("temp.mp4", "wb") as f:
f.write(uploaded_file.getbuffer())
ffmpeg.input("temp.mp4").output("temp.mpg", vcodec="mpeg1video").run()
# Attempt to open with OpenCV
cap = cv2.VideoCapture("temp.mpg")
if not cap.isOpened():
st.error("Error: Could not open video.")
else:
ret, frame = cap.read()
st.image(frame)
Код: Выделить всё
OpenCV(4.6.0) error: (-5:Bad argument) CAP_IMAGES: can't find starting number in the name of file: temp.mpg in function 'cv::icvExtractPattern'
Что я пробовал:
- Преобразование видео в формат .mpg с помощью ffmpeg, как показано.
- Проверка разрешений и путей к файлам.
- Python 3.9
- OpenCV 4.6.0
Streamlit 1.4.0 - ffmpeg-python
Подробнее здесь: https://stackoverflow.com/questions/791 ... g-uploaded