Skip to content
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

Reading from UDP, PyAv is blocked? #325

Closed
SkytreeRom opened this issue May 16, 2018 · 3 comments
Closed

Reading from UDP, PyAv is blocked? #325

SkytreeRom opened this issue May 16, 2018 · 3 comments

Comments

@SkytreeRom
Copy link

We read source file from UDP using av.open() function, and then decode each frame with container.decode(). It works well when UDP stream is stable. But when UDP stream stops, the program will get blocked at the decode line forever. Moreover, if we open a wrong UDP stream, the program will also get blocked.
Can someone give us some suggestions about this problem? THANKS!
P.S. We have thought about using python's decorator by setting a fixed time to terminate the blocked process, but it doesn't meet our need. We want dynamically terminate the blocked process, which input UDP stream has stopped.

@mikeboers
Copy link
Member

You're opening with something like av.open('udp://foo')?

If you look at the FFmpeg docs there is a timeout option. Perhaps that could be set quite low. Maybe even zero.

I wonder if there is a way to nicely know how much data is has received.

@DFjackdaw
Copy link

We do use av.open('udp://foo') to connect a nonexistent udp address, it will get blocked.

We try av.open('udp://foo?timeout=0') , it seems not work . Still blocked. So is there another way to jump out? Or we just write the wrong codes?

And how about container.decode()?When the sender stop udp stream, it blocked. Any option or parameter to terminate the blocked process?

@SkytreeRom
Copy link
Author

SkytreeRom commented May 17, 2018

THANKS! @mikeboers
We have fixed this problem with the latest version (0.4.1). Using a simple parameter timeout(e.g. 'udp://127.0.0.1:6666?timeout=2000'), PyAv will automatically handle all possible problems when you decode() or open().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants