whitphx/streamlit-webrtc

Video recording freezes using MediaRecorder

Spisor opened this issue · 0 comments

Hi!

Thank you for implementing this component; I found it really useful!

I am having some trouble recording the input video using the cookbooks/examples provided in the code.

My current code looks like this:

from aiortc.contrib.media import MediaRecorder

from streamlit_webrtc import WebRtcMode, webrtc_streamer


def app():
    def recorder_factory() -> MediaRecorder:
        return MediaRecorder("test1.mp4")
    
    webrtc_streamer(
        key="loopback",
        mode=WebRtcMode.SENDRECV,
        rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]},
        media_stream_constraints={
            "video": True,
            "audio": True,
        },
        in_recorder_factory=recorder_factory
    )

if __name__ == "__main__":
    app()

This code is similar to the example provided. However, after a few seconds, the video recording freezes and only the audio continues to record.

The error I am receiving is:

[libx264 @ 000001f7b1525180] non-strictly-monotonic PTS
[mp4 @ 000001f78f20b940] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 22016 >= 22016

Should I use some other options in the MediaRecorder from the aiortc library?

I noticed that some people encounter the same error with aiortc MediaRecorder when using HLS, but that is not my case.

Thank you for your assistance!