OpenVisualCloud / SVT-HEVC

SVT HEVC encoder. Scalable Video Technology (SVT) is a software-based video coding technology that is highly optimized for Intel® Xeon® processors. Using the open source SVT-HEVC encoder, it is possible to spread video encoding processing across multiple Intel® Xeon® processors to achieve a real advantage of processing efficiency.
Other
517 stars 171 forks source link

SVT FFMPEG ignore rate option #489

Closed raztexel closed 4 years ago

raztexel commented 4 years ago

Hi, I am trying to use SVT with FFMPEG and generate high VQ HEVC video. The VQ is fairly the same with any -preset value. I have tried to set rate to increase VQ using -b:v16M and the VQ still poor and generated rate is around 0.8 mbps This is the command: ffmpeg -ss 08:00 -i xxxxx \ -filter_complex idet,yadif=deint=interlaced:mode=2,scale=1920:960,crop=960:960:0:0 \ -c:v libsvt_hevc -vframes 600 -b:v 6M -umv 0 -forced-idr 50 -sc_detection false -rc cqp -r 50 -g 50 \ -c:a aac a.ts -y

This is the encoding output: Please use -b:a or -b:v, -b is ambiguous Stream mapping: Stream #0:0 (mpeg2video) -> idet (graph 0) crop (graph 0) -> Stream #0:0 (libsvt_hevc) Stream #0:1 -> #0:1 (mp2 (native) -> aac (native)) Press [q] to stop, [?] for help SVT [version]: SVT-HEVC Encoder Lib v1.4.3 SVT [build] : GCC 7.4.0 64 bit LIB Build date: Feb 17 2020 10:52:14

Number of logical cores available: 6 Number of PPCS 92


SVT [config]: Main Profile Tier (auto) Level (auto)
SVT [config]: EncoderMode / Tune : 7 / 1 SVT [config]: EncoderBitDepth / CompressedTenBitFormat / EncoderColorFormat : 8 / 0 / 1 SVT [config]: SourceWidth / SourceHeight / InterlacedVideo : 960 / 960 / 0 SVT [config]: Fps_Numerator / Fps_Denominator / Gop Size / IntraRefreshType : 50 / 1 / 50 / 50 SVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure : 3 / 0 / 2 SVT [config]: BRC Mode / QP / LookaheadDistance / SceneChange : CQP / 32 / 17 / 0 SVT [config]: BitRateReduction / ImproveSharpness : 0 / 0 SVT [config]: tileColumnCount / tileRowCount / tileSliceMode / Constraint MV : 1 / 1 / 0 / 1 SVT [config]: De-blocking Filter / SAO Filter : 1 / 1 SVT [config]: HME / UseDefaultHME : 1 / 1 SVT [config]: MV Search Area Width / Height : 16 / 7 SVT [config]: HRD / VBV MaxRate / BufSize / BufInit : 0 / 0 / 0 / 90


Output #0, mpegts, to 'a.ts': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: hevc (libsvt_hevc), yuv420p, 960x960 [SAR 8:9 DAR 8:9], q=10-48, 50 fps, 90k tbn, 50 tbc Metadata: encoder : Lavc58.54.100 libsvt_hevc Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.54.100 aac frame= 600 fps= 53 q=-0.0 Lsize= 2509kB time=00:00:24.14 bitrate= 851.2kbits/s speed=2.14x

This is the rate as reported by ffplay: ffplay version N-96442-g8c3e9c9cbb Copyright (c) 2003-2020 the FFmpeg developers built with Apple LLVM version 10.0.1 (clang-1001.0.46.4) configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --samples=fate-suite libavutil 56. 38.100 / 56. 38.100 libavcodec 58. 66.100 / 58. 66.100 libavformat 58. 35.104 / 58. 35.104 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 71.100 / 7. 71.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Input #0, mpegts, from 'a.ts': Duration: 00:00:24.12, start: 1.518667, bitrate: 852 kb/s

intelmark commented 4 years ago

@raztexel - To use a bitrate in the encoding the bitrate control mode should be variable (VBR) and not constant CQP.

Also is there a reason for setting umv to 0 since there is no tiling defined (tileColumnCount = tileRowCount = 1)?

tianjunwork commented 4 years ago

Hi @raztexel you use -rc cqp in your command line, and svt-hevc encoder gets BRC Mode / QP / LookaheadDistance / SceneChange : CQP / 32 / 17 / 0. It is CQP brc with qp value 32.

raztexel commented 4 years ago

I have tried to run with "-rc 1" and now the bitrate averages around the rate that I want I am using "-b:v" flag for the video rate. What is the recommended way to generate CBR rate with ffmpeg-svt? Which flag should I use to get "near original VQ"?

tianjunwork commented 4 years ago

SVT-HEVC plugin supports ffmpeg -b:v, -maxrate, -bufsize options. https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate

which maps to targetBitRate , vbvMaxrate, vbvBufsize SVT interface.

param->targetBitRate = avctx->bit_rate;
param->vbvMaxrate = avctx->rc_max_rate;
param->vbvBufsize = avctx->rc_buffer_size;

For your second question, it highly depends on input resolution, content complexity and stream usage. There are some recommended bitrate setting guideline online. E.g. https://support.google.com/youtube/answer/1722171?hl=en