Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

FFmpeg-qsv encoding failed when NumMbPerSlice < 50 #864

Closed
lizhong1008 opened this issue Nov 5, 2018 · 6 comments
Closed

FFmpeg-qsv encoding failed when NumMbPerSlice < 50 #864

lizhong1008 opened this issue Nov 5, 2018 · 6 comments
Labels
P1 Very important to be fixed

Comments

@lizhong1008
Copy link
Contributor

Apply patch: https://patchwork.ffmpeg.org/patch/10778/
Then run:
./ffmpeg -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 -vframes 100 -c:v h264_qsv -flags qscale -global_quality 25 -num_mb_per_slice 49 -y test.mp4 -loglevel verbose

Encoding failed with error message:
[h264_qsv @ 0x2e9b480] Error during encoding: device failed (-17)
Video encoding failed

if set num_mb_per_slice >=50, everything is ok.

The test input clip can be downloaded from: http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4

@dvrogozh
Copy link
Contributor

dvrogozh commented Nov 7, 2018

@lizhong1008 : https://patchwork.ffmpeg.org/patch/10778/ does not apply by itself, it has some prerequisites. Could you, please, list them all here?

@lizhong1008
Copy link
Contributor Author

@dvrogozh , I don't know why ffmpeg patchwork just received 5 patches (7 patches in this series).
However, you can get all of them from intel-media-ci/ffmpeg#4

@dvrogozh
Copy link
Contributor

Input stream is 1920x1088 meaning 120x68=8160 macroblocks. For 49 mb per slices we should have 167 slices. Issues happens on writing slices data for the 2nd or 3rd frame (not the first frame for sure) when encoder starts to write slice with the first_mb_inslice=8036. mediasdk h264 encoder throws an exception writing slices data from here:

Eventually we have less space in the output buffer allocated than needed. @stasefremov, @ogolikov : can you, please, suggest why this can happen?

@dvrogozh dvrogozh added the P1 Very important to be fixed label Nov 20, 2018
@lizhong1008
Copy link
Contributor Author

Any update?

1 similar comment
@andreasunterhuber
Copy link

Any update?

ogolikov added a commit to ogolikov/MediaSDK that referenced this issue Jan 16, 2019
onabiull pushed a commit that referenced this issue Jan 17, 2019
@dvrogozh
Copy link
Contributor

dvrogozh commented Jan 17, 2019

After 58835b0 I see error gone for num_mb_per_slice=49, but now it (this can be other error inside mediasdk, but it has the same signature on ffmpeg level) happens on the threshold of 31/32 (at least in case of my clip):

ffmpeg \
  -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 -vframes 100 \
  -c:v h264_qsv -flags qscale -global_quality 25 -num_mb_per_slice 31 -mfmode off -y test.mp4 -loglevel verbose
[h264_qsv @ 0x1fe6180] Using the constant quantization parameter (CQP) ratecontrol method
[h264_qsv @ 0x1fe6180] MFMode:1
[AVHWDeviceContext @ 0x21cb440] VAAPI driver: Intel iHD driver - 1.0.0.
[AVHWDeviceContext @ 0x21cb440] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x207fb00] libva: Save context 0x20000000 into log file /home/dvrogozh/trace/file.105439.thd-0x000050f8
[h264_qsv @ 0x1fe6180] Warning in encoder initialization: incompatible video parameters (5)
[h264_qsv @ 0x1fe6180] profile: high; level: 40
[h264_qsv @ 0x1fe6180] GopPicSize: 250; GopRefDist: 4; GopOptFlag: ; IdrInterval: 0
[h264_qsv @ 0x1fe6180] TargetUsage: 4; RateControlMethod: CQP
[h264_qsv @ 0x1fe6180] QPI: 0; QPP: 0; QPB: 1
[h264_qsv @ 0x1fe6180] NumSlice: 264; NumRefFrame: 3
[h264_qsv @ 0x1fe6180] RateDistortionOpt: OFF
[h264_qsv @ 0x1fe6180] RecoveryPointSEI: OFF IntRefType: 0; IntRefCycleSize: 0; IntRefQPDelta: 0
[h264_qsv @ 0x1fe6180] MaxFrameSize: 0; MaxSliceSize: 0;
[h264_qsv @ 0x1fe6180] BitrateLimit: ON; MBBRC: OFF; ExtBRC: OFF
[h264_qsv @ 0x1fe6180] Trellis: auto
[h264_qsv @ 0x1fe6180] RepeatPPS: OFF; NumMbPerSlice: 31; LookAheadDS: 2x
[h264_qsv @ 0x1fe6180] AdaptiveI: OFF; AdaptiveB: OFF; BRefType: pyramid
[h264_qsv @ 0x1fe6180] MinQPI: 0; MaxQPI: 0; MinQPP: 0; MaxQPP: 0; MinQPB: 0; MaxQPB: 0
[h264_qsv @ 0x1fe6180] Entropy coding: CABAC; MaxDecFrameBuffering: 3
[h264_qsv @ 0x1fe6180] NalHrdConformance: OFF; SingleSeiNalUnit: ON; VuiVclHrdParameters: OFF VuiNalHrdParameters: OFF
[h264_qsv @ 0x1fe6180] FrameRateExtD: 1; FrameRateExtN: 30
*** 2 dup!
[AVHWDeviceContext @ 0x207fb00] libva: Open new log file /home/dvrogozh/trace/file.105439.thd-0x00005102 for the thread 0x00005102
[h264_qsv @ 0x1fe6180] Error during encoding: device failed (-17)
Video encoding failed
[AVIOContext @ 0x1fdba40] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x1fb44c0] Statistics: 350943 bytes read, 2 seeks

@ogolikov : threshold of 32 is suspicious... Are there any natural limitation for the parameter to be >=32? or that's some other issue under the hood?

dvrogozh pushed a commit to dvrogozh/MediaSDK that referenced this issue Jan 24, 2019
dvrogozh pushed a commit to dvrogozh/MediaSDK that referenced this issue Jan 28, 2019
dvrogozh pushed a commit to dvrogozh/MediaSDK that referenced this issue Jan 28, 2019
dvrogozh pushed a commit to dvrogozh/MediaSDK that referenced this issue Feb 5, 2019
dvrogozh pushed a commit to dvrogozh/MediaSDK that referenced this issue Feb 6, 2019
jonrecker pushed a commit to jonrecker/MediaSDK that referenced this issue Feb 19, 2019
jonrecker pushed a commit to jonrecker/MediaSDK that referenced this issue Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Very important to be fixed
Projects
None yet
Development

No branches or pull requests

3 participants