[FFmpeg-trac] #7629(avcodec:new): VAAPI: HEVC (h265) VBR encode bitrate way too low
FFmpeg
trac at avcodec.org
Wed Dec 19 10:16:45 EET 2018
#7629: VAAPI: HEVC (h265) VBR encode bitrate way too low
------------------------------------+-----------------------------------
Reporter: uartie | Owner:
Type: defect | Status: new
Priority: normal | Component: avcodec
Version: git-master | Resolution:
Keywords: vaapi | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+-----------------------------------
Comment (by lizhong1008):
Took a quick look at this issue. I believe this is a i965 driver instead
of ffmpeg issue.
Here are the file size of encoded bitstreams via FFmpeg with same bitrate
setting as bug description but just changing encoder type and BRC
mode.(prefix "i965" means i965 driver, "ihd" means iHD driver)
ls -ls test_*
2564 -rw-r--r-- 1 root root 2624921 12月 19 15:19 test_i965_cbr.h265
2560 -rw-r--r-- 1 root root 2621123 12月 19 15:17 test_i965.h264
384 -rw-r--r-- 1 root root 391474 12月 19 15:19 test_i965_vbr.h265
2556 -rw-r--r-- 1 root root 2613360 12月 19 15:19 test_ihd_cbr.h265
2536 -rw-r--r-- 1 root root 2596236 12月 19 15:17 test_ihd.h264
2556 -rw-r--r-- 1 root root 2617061 12月 19 15:18 test_ihd_vbr.h264
2544 -rw-r--r-- 1 root root 2604431 12月 19 15:20 test_ihd_vbr.h265
You can see the file size is not normal for "i965 driver + VBR mode +
HEVC" case, any other cases are normal.
Checked i965 driver: https://github.com/intel/intel-vaapi-
driver/blob/master/src/gen9_hevc_encoder.c#L1770
You can find the case "target_percentage <=
HEVC_BRC_MIN_TARGET_PERCENTAGE" hasn't been handled.
HEVC_BRC_MIN_TARGET_PERCENTAGE is 50, but gstreamer-vaapi always set it to
be 70 for VBR (see: https://github.com/GStreamer/gstreamer-
vaapi/blob/master/gst-libs/gst/vaapi/gstvaapiencoder.c#L939), so this
gstreamer-vaapi won't trigger it.
Current setting will make target_percentage=50 in FFmpeg (see:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vaapi_encode.c#L1344)
and then trigger the driver issue.
To further make sure, I have tried to set the maxrate to be 7M (then
target_percentage is larger then 50):
LIBVA_DRIVER_NAME=i965 ./ffmpeg -hwaccel vaapi -vaapi_device
/dev/dri/renderD128 -v verbose -f rawvideo -pix_fmt yuv420p -s:v 1920x1080
-r:v 30 -i /root/Videos/1080p_blue_sky.yuv -vf 'format=nv12,hwupload' -c:v
hevc_vaapi -b:v 4000k -maxrate 7000k -vframes 150 -y
test_i965_maxrate7M_vbr.h265
ls -ls test_i965_maxrate7M_vbr.h265
2626930 12月 19 15:51 test_i965_maxrate7M_vbr.h265
echo "2626930*8*30/1024.0/150" |bc
4104
You can see the encoded bit-rate is close to target bit-rate.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7629#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list