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
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:
from pathlib import Path
import sys
import av
# Comment this out and it doesn't hang
import torchvision.transforms.v2.functional
THIS_DIR = Path(__file__).parent
vids = THIS_DIR.glob('*.mp4')
for vid in vids:
print('VID:', vid)
sys.stdout.flush()
with av.open(vid, mode='r') as container:
assert len(container.streams.video) == 1
# Comment this out and it doesn't hang
container.streams.video[0].thread_type = 'AUTO'
for i, frame in enumerate(container.decode(video=0)):
print('Frame:', frame)
sys.stdout.flush()
if i == 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 report this to torchvision 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
This discussion was converted from issue #1849 on April 01, 2025 06:14.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
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:
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 report this to torchvision 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.txtfile that reproduces the issue with Python 3.10.6All reactions