PyNvVideoCodec SimpleDecoder crashes on certain videos

On some files PyNvVideoCodec SimpleDecoder crashes. No error output at all. In the below example directly, for other video files at some frame. Most video files work fine.

The worst thing is that there seems no way to catch this error with python.

OS: Windows 10 Enterprise 22H2

PyNvVideoCodec Version: 2.1.0

Driver: 32.0.15.7700 (I have issues updating due to corperate policies)

link to video: https://www.pexels.com/video/a-subway-train-is-stopped-at-a-station-18553046/

code:

import os

import PyNvVideoCodec as nvc

video_path = “18553046-uhd_3840_2160_30fps.mp4”

os.environ[“LOGGER_LEVEL”] = “DEBUG”

decoder = nvc.SimpleDecoder(

video_path,

gpu_id=0,

output_color_type=nvc.OutputColorType.RGBP,

need_scanned_stream_metadata=True,

)

print(“loaded”)

output:

[h264 @ 000002A333EAF500] no picture

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A334142100] demuxer injecting skip 2048 / discard 0

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A334142100] All info found

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A334142100] After avformat_find_stream_info() pos: 2303960 bytes read:2336223 seeks:0 frames:16

[AVFormatContext @ 000002A33416C580] Opening ‘18553046-uhd_3840_2160_30fps.mp4’ for reading

[file @ 000002A3340D3440] Setting default whitelist ‘file,crypto,data’

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] ISO: File Type Major Brand: mp42

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Unknown dref type 0x206c7275 size 12

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Processing st: 0, edit list 0 - media time: 3003, duration: 941900

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Offset DTS by 3003 to make first pts zero.

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Setting codecpar->delay to 2 for stream st: 0

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Unknown dref type 0x206c7275 size 12

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Processing st: 1, edit list 0 - media time: 2048, duration: 1510400

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] drop a frame at curr_cts: 0 @ 0

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] drop a frame at curr_cts: 1024 @ 1

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] Before avformat_find_stream_info() pos: 19732 bytes read:32768 seeks:0 nb_streams:2

[h264 @ 000002A333EAF500] nal_unit_type: 7(SPS), nal_ref_idc: 3

[h264 @ 000002A333EAF500] Decoding VUI

[h264 @ 000002A333EAF500] nal_unit_type: 8(PPS), nal_ref_idc: 3

[h264 @ 000002A333EAF500] nal_unit_type: 7(SPS), nal_ref_idc: 3

[h264 @ 000002A333EAF500] Decoding VUI

[h264 @ 000002A333EAF500] nal_unit_type: 8(PPS), nal_ref_idc: 3

[h264 @ 000002A333EAF500] nal_unit_type: 6(SEI), nal_ref_idc: 0

[h264 @ 000002A333EAF500] nal_unit_type: 5(IDR), nal_ref_idc: 3

[h264 @ 000002A333EAF500] Format yuv420p chosen by get_format().

[h264 @ 000002A333EAF500] Reinit context to 3840x2160, pix_fmt: yuv420p

[h264 @ 000002A333EAF500] no picture

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] demuxer injecting skip 2048 / discard 0

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] All info found

[mov,mp4,m4a,3gp,3g2,mj2 @ 000002A33416C580] After avformat_find_stream_info() pos: 2303960 bytes read:2336223 seeks:0 frames:16

[AVIOContext @ 000002A33403AA80] Statistics: 98758271 bytes read, 0 seeks

[h264 @ 000002A333EAFC40] nal_unit_type: 7(SPS), nal_ref_idc: 3

[h264 @ 000002A333EAFC40] Decoding VUI

[h264 @ 000002A333EAFC40] nal_unit_type: 8(PPS), nal_ref_idc: 3

Hi @felix.ulomek
thanks for reporting, we are taking a look.

Hi @felix.ulomek ,
To help isolate the issue, could you please let us know if the error shows up when need_scanned_stream_metadata is set to False?

Yes, not setting need_scanned_stream_meta is my default setting. No difference except about the first half of debug output is missing

Also encountered similar problem. Certain videos native crashs when creating SimpleDecoder. Any fixes so far?

Hi @felix.ulomek and @whq1997430 ,
Apologies for the delayed update. PyNvVideoCodec 2.0.4 has been released, and the issue is resolved in this version.