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
I am using pims.PyAVReaderIndexed to create a toc of my video file to eventually index frames precisely in my files.
The problem is that the decoding takes a very long time (too long). See also a previous mention of this #425
For the threading part I noticed a weirdness that the last frames are dropped - I have documented the issue here PyAV-Org/PyAV#1098. I am not 100% sure this is a PIMS or a pyAV issue, this is why I am reporting it here again.
The only change I introduced was the stream.thread_type = "AUTO" flag.
classPyAVReaderIndexed_Multi(PyAVReaderIndexed):
""" Slightly changed version of "PyAVReaderIndexed" in pims Adds multi thread support to toc building as described here https://pyav.org/docs/stable/cookbook/basics.html#threading """def__init__(self, file, toc=None, format=None):
ifnothasattr(file, 'read'):
file=str(file)
self.file=fileself.format=formatself._container=Nonewithav.open(self.file, format=self.format) ascontainer:
stream= [sforsincontainer.streamsifs.type=='video'][0]
stream.thread_type="AUTO"# This is what enables multithreading# Build a tociftocisNone:
packet_lengths= []
packet_ts= []
forpacketincontainer.demux(stream):
ifpacket.stream.type=='video':
decoded=packet.decode()
iflen(decoded) >0:
packet_lengths.append(len(decoded))
packet_ts.append(decoded[0].pts)
self._toc= {
'lengths': packet_lengths,
'ts': packet_ts,
}
else:
self._toc=tocself._toc_cumsum=np.cumsum(self.toc['lengths'])
self._len=self._toc_cumsum[-1]
# PyAV always returns frames in color, and we make that# assumption in get_frame() later below, so 3 is hardcoded here:self._im_sz=stream.height, stream.width, 3self._time_base=stream.time_baseself._load_fresh_file()
Are there any ideas for why the packages are dropped in the multi threading case, and does anybody have suggestions on how to improve toc / decoding?
The text was updated successfully, but these errors were encountered:
I am using
pims.PyAVReaderIndexed
to create a toc of my video file to eventually index frames precisely in my files.The problem is that the decoding takes a very long time (too long). See also a previous mention of this #425
I can see two possible ways to gain some speed:
For the threading part I noticed a weirdness that the last frames are dropped - I have documented the issue here PyAV-Org/PyAV#1098. I am not 100% sure this is a PIMS or a pyAV issue, this is why I am reporting it here again.
The only change I introduced was the
stream.thread_type = "AUTO"
flag.Are there any ideas for why the packages are dropped in the multi threading case, and does anybody have suggestions on how to improve toc / decoding?
The text was updated successfully, but these errors were encountered: