Real time app with video and pdf viewer

I make app which visualizate 3 cameras in real time(in while) and 1 statical pdf(outide loop) 1.5Mb with text and images.
If I use only cameras I have around 5 fps, if I add pdf it become less than 1.
I trued use cache. but this not help

@st.cache_data
def pdf():
    with st.sidebar:
        st.markdown(pdf_viewer.show_pdf(st.session_state.pdf_file_path), unsafe_allow_html=True)
# Function to read PDF and return content
@st.cache_data
def read_pdf(file_path):
    # Replace with your PDF reading logic
    with open(file_path, "rb") as f:
        base64_pdf = base64.b64encode(f.read()).decode("utf-8")
    return base64_pdf


# Function to display PDF content
@st.cache_data
def display_pdf(base64_pdf):
    pdf_display = f'<embed src="data:application/pdf;base64, {base64_pdf}" width="500" height="600"  ' \
                  f'type="application/pdf"> '

    return pdf_display


@st.cache_data
def show_pdf(pdf_file_path):
    pdf_content = read_pdf(pdf_file_path)
    pdf_display = display_pdf(pdf_content)

    return pdf_display

Locally
Streamlit 1.31 and Python 3.11

Hi @alma

Have you tried reducing the number of cameras from 3 to 1 and 1 PDF file to see how much fps you are getting as well as 2 cameras and 1 PDF, as well as other options like 1 camera and no PDF, 2 cameras and no PDF.

I trued 2, 3 cameras with and without pdf
with pdf it lagging with 2 and 3. at approx same.
without it work nice with 2 and 3 cameras

lagging not only cameras but also app scrolling