Opened 9 months ago

Closed 9 months ago

Last modified 8 months ago

#7502 closed defect (fixed)

VAAPI encoding on Coffee Lake skipping/missing frames

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

Description

Summary of the bug:

Using h264_vaapi encoder on an Ubuntu 16.04 with Intel i9-8700 on .mov input outputs video stream with only keyframes. The result is a video with still frames changing every 3-5 seconds.

The same encoder (h264_vaapi) works normally on other h264 input.
Using -intra with h264_vaapi outputs all frames correctly.
Switching from h264_vaapi to hevc_vaapi encodes properly with all frames.

ffmpeg version 4.02 built on docker container (vaapi) from https://hub.docker.com/r/jrottenberg/ffmpeg/
problem also occurs on the 3.x container

How to reproduce:

% ffmpeg -stats -report -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -hwaccel vaapi -t 30 -i input.mov -an -filter_complex "format=nv12|vaapi,hwupload" -c:v h264_vaapi -qp 28 -bf 0 -compression_level 0 -quality 0 output.mp4 -y

Attachments (4)

ffmpeg-20181019-095930.log (724.5 KB) - added by dseeker 9 months ago.
report of file
ffmpeg-20181019-095956.log (842.2 KB) - added by dseeker 9 months ago.
report h264_vaapi intra
ffmpeg-20181019-100017.log (725.2 KB) - added by dseeker 9 months ago.
report hevc_vaapi
vaapi_skipping-frames_h264.mp4 (2.4 MB) - added by dseeker 9 months ago.
h264_vaapi output skipping frames

Change History (11)

Changed 9 months ago by dseeker

report of file

Changed 9 months ago by dseeker

report h264_vaapi intra

Changed 9 months ago by dseeker

report hevc_vaapi

Changed 9 months ago by dseeker

h264_vaapi output skipping frames

comment:1 Changed 9 months ago by dseeker

PS: I tried connecting to the FTP to upload the source but it's timing out
here's a google drive link to the source
https://drive.google.com/open?id=1PpB7J4rjoDhi82dy6K9BR1JBbbdB6vfD

comment:2 Changed 9 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords h264 linux coffeelake intel quicksync removed

Please test current FFmpeg git head and provide the log file, no other version is supported here.

comment:3 Changed 9 months ago by jkqxz

Can you try with <https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235692.html> applied?

The only problem I can see here is that the SAR gets written incorrectly because it doesn't fit in the 216 range. I'm not sure how that causes the observed issue, but fixing it seems to help.

That is, if I fix the SAR in your file with:

ffmpeg -i vaapi_skipping-frames_h264.mp4 -c:v copy -bsf:v h264_metadata=sample_aspect_ratio=1 output.mp4

then the output file plays correctly where the input did not.

comment:4 Changed 9 months ago by dseeker

@jkqxz yes changing the sample_aspect_ratio did correct all the frame encoding, even thou the aspect ratio got distorted. I'll try to get the value somewhere else and enforce it.

I noted this message when trying to re-encode the file for testing, may have something to do with it?

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5598d1728000] sample aspect ratio already set to 93207:65536, ignoring 'pasp' atom (118:81)

I will try to update the build, but since I'm using the hosted docker container I haven't a clue how to update the branch there.

comment:5 Changed 9 months ago by dseeker

This fraction problem seems to extend beyond the vaapi encoder. The same content outputs incorrectly with image extraction (png or jpg). it's necessary to manually add scaling with the appropriate AR to adjust, otherwise the output scaling is incorrect.

I couldn't test the new branches, but was able to fix all the problems with manually overriding the AR truncating to 6 digits

comment:6 Changed 9 months ago by dseeker

  • Resolution set to worksforme
  • Status changed from new to closed

comment:7 Changed 8 months ago by cehoyos

  • Component changed from undetermined to avcodec
  • Resolution changed from worksforme to fixed
  • Version changed from unspecified to git-master
Note: See TracTickets for help on using tickets.