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
Exiting frames loop with torchvision installed hangs foreve #1861
I reported the following bug in #1849 which as closed as it was believed it was fixed with an upgrade to a newer version of ffmpeg. However, I just upgraded to 14.3.0, which uses that newer version of ffmpeg (per av.ffmpeg_version_info it is 7.1.1) and the bug described below is still present. I would have just re-opened the original bug, but since it was converted to a conversation that doesn't seem to be possible.
Original bug:
Using torchvision with av with video threading mode of AUTO or FRAME causes a hang. Note, you don't even need to use torchvision, just importing it causes the issue.
Minimal reproducing example:
frompathlibimportPathimportsysimportav# Comment this out and it doesn't hangimporttorchvision.transforms.v2.functionalTHIS_DIR=Path(__file__).parentvids=THIS_DIR.glob('*.mp4')
forvidinvids:
print('VID:', vid)
sys.stdout.flush()
withav.open(vid, mode='r') ascontainer:
assertlen(container.streams.video) ==1# Comment this out and it doesn't hangcontainer.streams.video[0].thread_type='AUTO'fori, frameinenumerate(container.decode(video=0)):
print('Frame:', frame)
sys.stdout.flush()
# Comment out the early exit and it doesn't hangifi==2:
break
The keys here are (1) you have to import torchvision - if you don't it works fine (2) you have to specify thread_type = 'AUTO' or thread_type = 'FRAME' or it doesn't hang and (3) you have to stop decoding the video before you reach the end - if you decode all frames it's fine.
What happens is it hits the break line but doesn't actually break - it just hangs. I have also pytorch/vision#9010 as it's not clear whose bug it is.
I think this will happen on just about any video but, if not, I'm happy to provide the mp4 files that are exhibiting the bug for me.
Here is a requirements.txt file that reproduces the issue with Python 3.10.6
Activity