Opened 2 years ago

Last modified 18 months ago

#8781 open defect

H.264 Decoding Fails on Raw Annex B Streams from VideoToolbox

Reported by: David Goodman Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: d3d11va
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
ffmpeg can successfully decode my stream of H264 Annex B NALs without a container (generated with VideoToolbox on an iOS device) using the x264 decoder, or even "-hwaccel cuda" on my Nvidia GPU, but fails when using d3d11va.

The bug seems to be in the d3d11va_validate_output() function in dxva2.c. I haven't been able to trace it down completely and create a proper fix yet, but I was able get decoding to work for my own use cases with a hacky workaround here: I'm forcing ffmpeg to use DXVA2_ModeH264_E regardless of the input stream, so this obviously isn't a proper solution.

How to reproduce:

% ffmpeg -hwaccel d3d11va -i h264_annexb_1440x1280.h264 output.mp4
'''ffmpeg version:'''
4.2.2 and 20200628-4cfcfb3
'''built on:'''
Downloaded from, and was able to reproduce with self-built 4.2.2 on Windows 10 1909.

Note that the white bottom half of my sample video is normal (it's an alpha channel).

Attachments (1)

ffmpeg-20200708-141619.log (562.2 KB ) - added by David Goodman 2 years ago.
Output log generated with -report

Download all attachments as: .zip

Change History (5)

by David Goodman, 2 years ago

Attachment: ffmpeg-20200708-141619.log added

Output log generated with -report

comment:1 by David Goodman, 2 years ago

I'm having trouble with the VideoLAN File Uploader, so here's a Google Drive link for a sample clip that makes causes the issue -- hope this is acceptable:

comment:2 by Balling, 20 months ago

Status: newopen

Unfortunately, we do not have h265_annexbtomp4 or even h264_annexbtomp4 but it is there (and other commits). After that we can tell whether this file is corrupted or not. Just saying.

comment:3 by Elon Musk, 20 months ago

File is invalid.

in reply to:  3 comment:4 by Balling, 20 months ago

Replying to richardpl:

File is invalid.

But we are not able to restore from Annex B back, are not we??

P.S. Looks like we can after all, sorry ;)

Last edited 18 months ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.