Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted HEVC encoded files on Tiger Lake #1190

Closed
angryziber opened this issue Apr 28, 2021 · 13 comments · Fixed by #1312
Closed

Corrupted HEVC encoded files on Tiger Lake #1190

angryziber opened this issue Apr 28, 2021 · 13 comments · Fixed by #1312
Assignees
Labels
Bug Issue: identify as a bug Encode video encode related HEVC HEVC In Progress PR: still under discussion P2 Medium priority

Comments

@angryziber
Copy link

angryziber commented Apr 28, 2021

Ubuntu 21.04
intel-media-va-driver-non-free 21.1.1+ds1-1
ffmpeg 7:4.3.2-0+deb11u1ubuntu1
CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Laptop: Asus Zenbook UX393E

When encoding a video to HEVC with ffmpeg & vaapi, no errors are given, but the output is corrupted (screenshot below).
VP9 and H264 files are encoded fine.

ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i $FILE -c:v hevc_vaapi -qp 27 -rc_mode ICQ -c:a copy $OUT

output:

[graph 0 input from stream 0:0 @ 0x556208026540] w:2720 h:1530 pixfmt:vaapi_vld tb:1/30000 fr:30000/1001 sar:1/1
[hevc_vaapi @ 0x5562070bb0c0] Using input frames context (format vaapi_vld) with hevc_vaapi encoder.
[hevc_vaapi @ 0x5562070bb0c0] Input surface format is nv12.
[hevc_vaapi @ 0x5562070bb0c0] Using VAAPI profile VAProfileHEVCMain (17).
[hevc_vaapi @ 0x5562070bb0c0] Using VAAPI entrypoint VAEntrypointEncSlice (6).
[hevc_vaapi @ 0x5562070bb0c0] Using VAAPI render target format YUV420 (0x1).
[hevc_vaapi @ 0x5562070bb0c0] RC mode: ICQ.
[hevc_vaapi @ 0x5562070bb0c0] RC quality: 27.
[hevc_vaapi @ 0x5562070bb0c0] RC framerate: 30000/1001 (29.97 fps).
[hevc_vaapi @ 0x5562070bb0c0] Using intra, P- and B-frames (supported references: 4 / 4).
[hevc_vaapi @ 0x5562070bb0c0] All wanted packed headers available (wanted 0xd, found 0x1f).
[hevc_vaapi @ 0x5562070bb0c0] Using level 5.
Output #0, mp4, to '20210428_233121.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: hevc (hevc_vaapi) (Main), 1 reference frame (hev1 / 0x31766568), vaapi_vld, 2720x1530 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.91.100 hevc_vaapi
@angryziber
Copy link
Author

mpv screenshot when playing back output file:
Screenshot from 2021-04-28 23-42-50

@angryziber
Copy link
Author

Just in case lspci -x:

0000:00:02.0 VGA compatible controller: Intel Corporation TigerLake GT2 [Iris Xe Graphics] (rev 01)
00: 86 80 49 9a 07 04 10 00 01 00 00 03 10 00 00 00
10: 04 00 00 3e 60 00 00 00 0c 00 00 00 40 00 00 00
20: 01 30 00 00 00 00 00 00 00 00 00 00 43 10 e2 13
30: 00 00 00 00 40 00 00 00 00 00 00 00 ff 01 00 00

@XinfengZhang XinfengZhang added Bug Issue: identify as a bug Encode video encode related P2 Medium priority labels May 16, 2021
@Xiaogangli-intel Xiaogangli-intel added the In Progress PR: still under discussion label Jul 6, 2021
@rmkimathi
Copy link

@fulinjie built latest ffmpeg master, got same corruption with hevc_vaapi encode on intel TGL

@Xiaogangli-intel
Copy link
Contributor

Thank you @rmkimathi, working on this issue, will update it once we have some progress.

@lobomfz
Copy link

lobomfz commented Oct 18, 2021

Is there any progress on this? i haven't been able to encode hevc for half a year

@Xiaogangli-intel Xiaogangli-intel added the HEVC HEVC label Oct 26, 2021
@georgnistor
Copy link

Hi,
I have the very same problem on i9-11900T
with UHD 750.

The setup I have is:
Open SUSE Tumbleweed 20211101 with ffmpeg 4.4.1
Kernel 5.14.14-1 64 bit
Mesa Intel Graphics

I am not able to encode with ffmpeg using va-api
ffmpeg -y -vaapi_device /dev/dri/renderD128 -i input.ts -vf 'format=nv12,hwupload' -c:v hevc_vaapi -b:v 6M -c:a copy out.mkv

@lobomfz
Did you find a solution?

@feiwan1
Copy link
Contributor

feiwan1 commented Nov 9, 2021

Hi @Xiaogangli-intel @XinfengZhang this may be caused by leak of VAConfigAttribEncHEVCFeatures&VAConfigAttribEncHEVCBlockSizes attrib report on TGL+ in media-driver. Previously Mark submitted a patch #866 which based on legacy interface. It need port to lastest libva interface. And I am not sure if Mark's patch is correct, in my understanding, TGL+ attrib should be sperated with common platform. So could you help to submit a new one ASAP? Since it blocks hevc encode on TGL+ by using upstream ffmpeg-vaapi. Only after the attrib report patch merged in media-driver, we can verify and submit ffmpeg-vaapi patch.
Also CC @lwan108 who reported some incorrect setting on Mark's patch.

@angryziber @lobomfz @georgnistor @rmkimathi, here is a workarround patch for ffmpeg-vaapi, which may fix your issue temporarily:
https://github.com/intel-media-ci/cartwheel-ffmpeg/blob/master/patches/0025-lavc-vaapi_encode_h265-fix-max_transform_hierarchy_d.patch

@rmkimathi
Copy link

Thank you @feiwan1

Workaround patch for ffmpeg fixes hevc_vaapi encode on TGL Xe Graphics.

@xhaihao
Copy link
Contributor

xhaihao commented Nov 11, 2021

@feiwan1 My understanding is that the added interfaces should be applied to TGL+ only, the legacy code works on ICL.

@feiwan1
Copy link
Contributor

feiwan1 commented Nov 11, 2021

Thanks @xhaihao for reminder. Current code works on ICL indeed. Just need to update TGL+'s code only. And corrected my previous comment.

@XinfengZhang
Copy link
Contributor

#1121

Tianhaol added a commit to Tianhaol/media-driver that referenced this issue Dec 13, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC VDENC.
Fixes intel#1190.
Tianhaol added a commit to Tianhaol/media-driver that referenced this issue Dec 13, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC VDENC.
Fixes intel#1190.
Tianhaol added a commit to Tianhaol/media-driver that referenced this issue Dec 14, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC VDENC.
Fixes intel#1190.
Tianhaol added a commit to Tianhaol/media-driver that referenced this issue Dec 15, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC.
Fixes intel#1190.
Tianhaol added a commit to Tianhaol/media-driver that referenced this issue Dec 17, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC.
Fixes intel#1190.
intel-mediadev pushed a commit that referenced this issue Dec 18, 2021
Fill in VAConfigAttribValEncHEVCFeatures and VAConfigAttribValEncHEVCBlockSizes
with the approriate values for HEVC.
Fixes #1190.
@flyingfalling
Copy link

I know this issue was closed, but I am still seeing this exact same behavior (ubuntu 22.04.1, ffmpeg 4.4.2).

intel core i5-1240P (12th gen)
VA-API 1.14 (libva 2.12.0)
iHD driver 22.3.1

I see the pull happened in intel media driver 22.5.4? So do I understand correctly that I will need a newer version than that to have this issue fixed?

@nyanmisaka
Copy link
Contributor

nyanmisaka commented Jun 10, 2023

@flyingfalling The ffmpeg fix exists in n5.1+ versions. Also make sure the ffmpeg is build against libva 2.12+.

FFmpeg/FFmpeg@9f02e03

intel/libva@1f895aa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issue: identify as a bug Encode video encode related HEVC HEVC In Progress PR: still under discussion P2 Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants