You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When I define and set pts and dts myself, the value of tbr will become 100 #1347
When I set the pts and dts myself, the btr will become 100 uncontrollably. When I don't modify the pts and dts, the value of the btr is consistent with the fps.
The problem is that it will cause video freezes and the video cannot be played at fps speed. The result of my analysis is that the speed of tbr must be consistent with the fps speed to avoid video freezes. In addition, I will write a demo to test it. @WyattBlue
This is a demo I wrote. As long as I enable the add_video_pts_dts method and set pts and dts myself, the tbr value in the rtmp stream will be greater than the fps value and become 100. As long as I do not set pts and dts myself, the tbr value will be the normal sum. Consistent fps @WyattBlue You try this demo
When I run it, I get this. I don't think it show cases the actual problem
Exception in thread Thread-2 (test_out):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1052, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "/Users/wyattblue/projects/auto-editor/test.py", line 58, in test_out
self.video_frame_duration, self.audio_frame_duration = self.get_frame_duration()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/wyattblue/projects/auto-editor/test.py", line 34, in get_frame_duration
in_video_stream = self.in_video_stream
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestAvLive' object has no attribute 'in_video_stream'
Connection to tcp://192.168.4.112:554?timeout=0 failed: Operation timed out
Exception in thread Thread-1 (test_in):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1052, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "/Users/wyattblue/projects/auto-editor/test.py", line 20, in test_in
self.in_video = av.open(self.rtsp, 'r', format=None, options=options, metadata_errors='strict')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "av/container/core.pyx", line 420, in av.container.core.open
File "av/container/core.pyx", line 266, in av.container.core.Container.__cinit__
File "av/container/core.pyx", line 286, in av.container.core.Container.err_check
File "av/error.pyx", line 328, in av.error.err_check
av.error.TimeoutError: [Errno 60] Operation timed out: 'rtsp://admin:abc@12345@192.168.4.112:554/ch1/stream1'; last error log: [tcp] Connection to tcp://192.168.4.112:554?timeout=0 failed: Operation timed out
If you enable the add_video_pts_dts method and set pts and dts yourself, it will cause tbr to become 100 instead of consistent with the value of fps, which will cause the video stream to freeze.
So my question is how to control the value of this tbr
def add_video_pts_dts(self, packet):
# return packet
for i in packet:
i.pts = i.dts = self.video_pts
self.video_pts += self.video_frame_duration
return packet
When I turn off the custom pts setting and set the time scale to 90000, the output mp4 file seems to be normal.
But if I output the rtmp stream, set the time scale to 90000 and turn off the custom pts setting, the picture will become very stuck. Only when the time scale is set to the same as the pts will it not be stuck. I don't understand why this happens.
Activity
WyattBlue commentedon Mar 25, 2024
btrDo you meantbr?Also, can you make a standalone example to show what exactly is the problem?
ncheng89 commentedon Mar 25, 2024
The problem is that it will cause video freezes and the video cannot be played at fps speed. The result of my analysis is that the speed of tbr must be consistent with the fps speed to avoid video freezes. In addition, I will write a demo to test it. @WyattBlue
ncheng89 commentedon Mar 26, 2024
This is a demo I wrote. As long as I enable the add_video_pts_dts method and set pts and dts myself, the tbr value in the rtmp stream will be greater than the fps value and become 100. As long as I do not set pts and dts myself, the tbr value will be the normal sum. Consistent fps @WyattBlue You try this demo
WyattBlue commentedon Mar 26, 2024
When I run it, I get this. I don't think it show cases the actual problem
ncheng89 commentedon Mar 26, 2024
You need to modify the addresses of rtmp and rtsp in the demo
ncheng89 commentedon Mar 26, 2024
If you enable the add_video_pts_dts method and set pts and dts yourself, it will cause tbr to become 100 instead of consistent with the value of fps, which will cause the video stream to freeze.
So my question is how to control the value of this tbr
WyattBlue commentedon Apr 4, 2024
Does this only happen in rtmp inputs? Can you replicate this in other rtmp streams?
ncheng89 commentedon Jun 14, 2024
Yes, I tested other rtmp streams and it was the same. I tried to write the input rtmp stream to an mp4 video file and it was the same.
This is the output result
When I try to change the time base to match the frame rate
video_stream.time_base = fractions.Fraction(1, fps)Get this result
ncheng89 commentedon Jun 14, 2024
When I turn off the custom setting pts, the output mp4 file seems to become normal, but I
When I turn off the custom pts setting and set the time scale to 90000, the output mp4 file seems to be normal.
But if I output the rtmp stream, set the time scale to 90000 and turn off the custom pts setting, the picture will become very stuck. Only when the time scale is set to the same as the pts will it not be stuck. I don't understand why this happens.