Skip to content

ffmpeg videoio module max packet read attempt #9455

@remia

Description

@remia

Noticed that I was getting error while reading some video files with opencv ffmpeg VideoCapture backend but those file were playing perfectly with no errors / warning everywhere else including ffplay.

Turns out that opencv will fails to grab a frame if more than 512 packets need to be read to reach the frame. See this code from video/src/cat_ffmpeg_impl.hpp :
const int max_number_of_attempts = 1 << 9;

I increased this to 1024 and now plays perfectly fine, maybe we should increase this number and maybe this would more clever to have one counter for packet read and another (much lower) for decoding attempts.

What do you think ?

The video file looks like this for information (many streams that explains why you need to read several hundred packets for some frame I think) :

Duration: 01:39:18.49, start: 0.000000, bitrate: 178953 kb/s
    Stream #0:0(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:1(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:2(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s    nan    :  0.000 fd=   0 aq=    0 (default)0KB sq=    0B f=0/0
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:3(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:4(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:5(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:6(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:7(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:8(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:9(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:10(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:11(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:12(und): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2017-07-04T07:48:06.000000Z
      handler_name    : Core Media Data Handler
      reel_name       : Daro_Logo_16x9_178_HD
      timecode        : 00:58:30:00
    Stream #0:13(und): Video: prores (apch / 0x68637061), yuv422p10le(bt709, progressive), 1920x1080, 165125 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2017-08-23T15:20:40.000000Z
      handler_name    : Gestionnaire d�alias Apple
      encoder         : Apple ProRes 422 HQ
      timecode        : 00:58:30:00

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions