Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mshabunin
Copy link
Contributor

@mshabunin mshabunin commented May 11, 2023

resolves #9455
related #3225

  • Use different counters for wrong packets recieved by demuxer and errors from decoder
  • Allow modifying these counters via environment variables OPENCV_FFMPEG_READ_ATTEMPTS/OPENCV_FFMPEG_DECODE_ATTEMPTS
  • Added logging when reading breaks at one of error limits

Notes:

  • I've been able to reproduce original issue with a video file with 14 total streams (video + audio + subtitles), at some point in the video only packets from the last stream are being sent by the demuxer, thus exceeding our limit. For my specific video total number of packets from wrong stream was about 2700. I've chosen 4096 as default value.
  • Default limit of decoding attempts is quite low, because I'm not sure in which cases it can be exceeded (network stream?). I tried to read 8k video from the disk, but it did not cause break at decode point.

@opencv-alalek opencv-alalek added this to the 4.8.0 milestone May 11, 2023
@asmorkalov
Copy link
Contributor

@opencv-alalek May I merge the patch?

@asmorkalov asmorkalov merged commit 001a2c5 into opencv:4.x May 16, 2023
@mshabunin mshabunin deleted the fix-ffmpeg-packet-limit branch May 16, 2023 14:26
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
videoio/FFmpeg: increased packet read attempt limit, allow configuring it

resolves opencv#9455
related opencv#3225

* Use different counters for wrong packets recieved by demuxer and errors from decoder
* Allow modifying these counters via environment variables `OPENCV_FFMPEG_READ_ATTEMPTS`/`OPENCV_FFMPEG_DECODE_ATTEMPTS`
* Added logging when reading breaks at one of error limits

Notes:
* I've been able to reproduce original issue with a video file with 14 total streams (video + audio + subtitles), at some point in the video only packets from the last stream are being sent by the demuxer, thus exceeding our limit. For my specific video total number of packets from wrong stream was about 2700. I've chosen 4096 as default value.
* Default limit of decoding attempts is quite low, because I'm not sure in which cases it can be exceeded (network stream?). I tried to read 8k video from the disk, but it did not cause break at decode point.
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
videoio/FFmpeg: increased packet read attempt limit, allow configuring it

resolves opencv#9455
related opencv#3225

* Use different counters for wrong packets recieved by demuxer and errors from decoder
* Allow modifying these counters via environment variables `OPENCV_FFMPEG_READ_ATTEMPTS`/`OPENCV_FFMPEG_DECODE_ATTEMPTS`
* Added logging when reading breaks at one of error limits

Notes:
* I've been able to reproduce original issue with a video file with 14 total streams (video + audio + subtitles), at some point in the video only packets from the last stream are being sent by the demuxer, thus exceeding our limit. For my specific video total number of packets from wrong stream was about 2700. I've chosen 4096 as default value.
* Default limit of decoding attempts is quite low, because I'm not sure in which cases it can be exceeded (network stream?). I tried to read 8k video from the disk, but it did not cause break at decode point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffmpeg videoio module max packet read attempt

3 participants