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

Why disable socket timeout temporarily in FormatContext::findStreamInfo? #90

Closed
ccsnake opened this issue Feb 1, 2021 · 3 comments
Closed
Assignees
Labels

Comments

@ccsnake
Copy link

ccsnake commented Feb 1, 2021

image

This will block in some cases.

thx

@ccsnake ccsnake changed the title Why disable socket timeout temporarily when FormatContext::findStreamInfo? Why disable socket timeout temporarily in FormatContext::findStreamInfo? Feb 1, 2021
@h4tr3d
Copy link
Owner

h4tr3d commented Feb 1, 2021

@ccsnake , thanks for report. Could you please attach code via code tags in textual format?

  1. It starts to be copyable.
  2. It still to be colorized
  3. It is simple to copy-paste code text.

According to your question, avformat_find_stream_info() for most header-less formats like MPEG-TS received via network requires a lot of time.

If you can provide a problematic source, that blocks in some cases call of the findStreamInfo(), I will debug it and provide a better solution.

@ccsnake
Copy link
Author

ccsnake commented Feb 1, 2021

thx for your reply.

Code location:

ScopedValue<int64_t> scopedTimeoutDisable(m_socketTimeout, -1, m_socketTimeout);

My programe may blocked when i opened a local IPC stream(rtsp) which has bad network. In my case I will open and close stream with fixed interval .

@h4tr3d h4tr3d self-assigned this Mar 4, 2021
@h4tr3d h4tr3d added the task label Mar 4, 2021
@h4tr3d
Copy link
Owner

h4tr3d commented Mar 5, 2021

I analyse code. av_find_stream_info() is a complex function that some times requires so much time for internal work. FormatContext::setTimeout() useful for simple cases and mainly targeted for use with FormatContext::readPacket(). For complex cases you should use FormatContext::setInterruptCallback(). In such way, you can setup some flag, that your callback check and return 1 if findStreamInfo is timed out.

In any case, socketTimeout() is not a good choose for this option name... Maybe frameReadTimeout() is better.

@h4tr3d h4tr3d closed this as completed Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants