New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error using MediaRecorder creating HLS segments #331
Comments
I unfortunately have no idea what's going on here, but there is a good chance the error stems from code outside |
I am running server.py as is described in the README, however the only difference is the the on track event at line 136: `
` I just want to save the captured video + audio for now, so i removed adding any local tracks to send back to the peer. I run it as Maybe this isnt an issue and I am just misunderstanding, are you required to add a local track to send to the peer connection? If i add Thanks for your insight. |
@tlaz4 Did you solve this? I have the same issue with the original MediaRecorder. On the random frame from client webcamera I get and MediaRecorder stop working further. @jlaine Can I avoid this exception if I don't need strict video especially in the internet stream? |
Hi, could You please provide HLSRecorder class (since I don't see it in source)? |
It seems HLSRecorder is just renamed MediaRecorder. Tried it that way and see also:
|
Hi, I encountered this problem with pc.addTrack(
VideoTransformTrack(
track, transform=params["video_transform"]
)
)
if args.record_to:
recorder.addTrack(track) This is not a solution since the two track consumers, |
Did anyone else happen to get to the bottom of this? I'm working through debugging for myself atm... Removing the |
I'm facing the same issue but intermittently. What I have noticed but it might only be coincidence is that when things are ok the I'm attaching two logs: Error case: https://gist.github.com/bmsan/f0f8d8191dcf781166470eed0f6e3e5c#file-example-with-error In the error case there can be seen 2 issues:
The second issue seems to appear when the packet dts doesn't increase (which can be seen at the end of the bad log. I've created a local workaround for the second issue(Which for me causes the crash) by dropping packages with nonincreasing DTS - but it is a dirty workaround because you lose some frames by doing this. - Initial testing seems to prevent the crashing error. @jlaine would you consider such a workaround(mentioned above) a candidate for a pull request? If so I can create one. |
After trying to understand more in depth what is going on, For other people looking at this, you can check if this is the case using the following computation inside MediaRecorder.__run_track()
For my hardcoded usecase(where I'm expecting 30FPS video streams), I created a MediaRecorderFixed30FPS, where I rewrite the frame.pts and frame.time_base information such that the encoder gets exactly 30 FPS. I see two more generic solutions:
|
@bmsan I wasn't able to get to the bottom and ended up writing the service I needed in node-webrtc instead which is working great for the time being. Just one comment on your "I'm expecting 30FPS video streams" — I'd be a little careful with that assumption if your consuming the other side of a MediaStream from a browser as I found in practice that you'll receive variable FPS depending on the quality of the connection |
@levistoddard Very good point. |
That is the cause: PyAV-Org/PyAV#730 |
@CLTanuki the behavior seems to be a little bit different, if I'm not understanding things wrong. In PyAV-Org/PyAV#730 there seems to be a check regarding the codec id that is failing In this issue we are not encountering the codec check fail, but the DTS of the transmitted packed is sometimes non-monotonically increasing(two consecutive packages might have the same DTS). This triggers an error in ffmpeg. This is due the instantaneous FPS of the webcam sometimes being slightly higher than 30 fps(the value that the MediaRecorder is configured with). |
@bmsan , this could not be fixed even with setting exact framerate for webcam. Only with patching framerate in MediaRecorder or setting pts and time_base manually, which is breaking manifest generation.
Not reproducing:
|
@CLTanuki I was thinking something in the lines that you mentioned:
|
It was not the case.
|
Hi, this is a great library.
I am attempting to use the MediaRecorder to create hls segments, but ffmpeg encounteres the following error during transmuxing:
Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2217000 >= 2217000
I am using the MediaRecorder as in the server example, except adding both audio and video tracks from a peer connection. The error only occurs on the video tracks, audio works perfectly.
I create the MediaRecorder objects as follows:
HLS_MANIFEST = "live/playlist.m3u8" HLS_SEGMENTS = "live/%s.ts" HLS_OPTS = { 'hls_list_size': '3', 'hls_time': '4', 'hls_segment_type': 'mpegts', 'hls_flags': 'delete_segments+discont_start', 'hls_start_number_source': 'datetime', 'strftime': '1', 'use_localtime': '1', 'hls_segment_filename': HLS_SEGMENTS, }
recorder = HLSRecorder(HLS_MANIFEST, format='hls', options=HLS_OPTS)
Any insight into this would be appreciated, thanks!
The text was updated successfully, but these errors were encountered: