[FFmpeg-user] Why ffmpeg libx265 generate way smaller files than cuda/nvidia based one?
jatmvp ctf
justanotherteammate at gmail.com
Fri Aug 5 18:02:00 EEST 2022
Hello,
I have problem with understanding why my ffmpeg with nVidia features (as
v:c hevc_nvenc) generate way larger file in comparison to libx265.
For the case I tried to reencode H.264 video and MP3 to AAC with merging it.
video.mp4 is H.264
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: dashmp42mp41iso6
creation_time : <not important>
Duration: 00:31:46.72, start: 0.000000, bitrate: 779 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661),
yuv420p(tv, bt709, progressive), 1920x1080, 0 kb/s, 25 fps, 25 tbr, 25 tbn
(default)
Metadata:
creation_time : <not important>
handler_name : L-SMASH Video Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
ffmpeg with nVidia CUDA support, choosend slowest preset and HQ tune (do
not worry about -nvidia suffix as I renamed ffmpeg.exe to distinguish
ffmpeg's in PATH):
> ffmpeg-nvidia -y -hwaccel cuda -hwaccel_output_format cuda
-extra_hw_frames 4 -i video.mp4 -i audio-converted.mp3 -c:v hevc_nvenc
-preset 18 -tune 1 -c:a aac -map 0:v:0 -map 1:a:0 output-nvidia-cuda.mp4
ffmpeg version N-107638-gb0cd979a0b Copyright (c) 2000-2022 the FFmpeg
developers
built with Microsoft (R) C/C++ wersja kompilatora optymalizującego
19.32.31332 dla x64
configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp
--toolchain=msvc --extra-cflags=-I../nv_sdk
--extra-ldflags='-libpath:../nv_sdk'
libavutil 57. 31.100 / 57. 31.100
libavcodec 59. 41.100 / 59. 41.100
libavformat 59. 29.100 / 59. 29.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 46.101 / 8. 46.101
libswscale 6. 8.101 / 6. 8.101
libswresample 4. 8.100 / 4. 8.100
[...]
Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), cuda(tv, bt709,
progressive), 1920x1080, q=2-31, 2000 kb/s, 25 fps, 12800 tbn (default)
[...]
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay:
N/A
[...]
frame=47668 fps=150 q=19.0 Lsize= 283611kB time=00:31:46.66
bitrate=1218.5kbits/s speed= 6x
video:252496kB audio:29738kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.488131%
[aac @ 000001E2F6673700] Qavg: 571.826
which makes about 290MBi (290403241, 1212 kb/s full trans speed) of video
output with music (127kb/s)
I tried with ffmpeg with nVidia with no preset nor tune set and the effect
was similar - it is faster but get way worse whan original size (h.264
about 180MB)
for installed from available resources ffmpeg running with CPU power
(preset is medium by default by wanted to be explicit; fastdecode - to ease
my output device when I watch or family, still not know if that have
anything to do as this is only 1080p but read it is for bottlenecks during
4K decode "hard frames/moments"):
> ffmpeg -i video.mp4 -i audio-converted.mp3 -c:v libx265 -preset medium
-tune fastdecode -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
same input
output:
ffmpeg version 2022-07-31-git-1368b5a725-full_build-www.gyan.dev Copyright
(c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static
--disable-w32threads --disable-autodetect --enable-fontconfig
--enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib
--enable-lzma --enable-libsnappy --enable-zlib --enable-librist
--enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth
--enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d
--enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e
--enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl
--enable-libopenjpeg --enable-libvpx --enable-mediafoundation
--enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi
--enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg
--enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec
--enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2
--enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo
--enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug
--enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame
--enable-libshine --enable-libtheora --enable-libtwolame
--enable-libvo-amrwbenc --enable-libilbc --enable-libgsm
--enable-libopencore-amrnb --enable-libopus --enable-libspeex
--enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite
--enable-libmysofa --enable-librubberband --enable-libsoxr
--enable-chromaprint
libavutil 57. 30.100 / 57. 30.100
libavcodec 59. 40.100 / 59. 40.100
libavformat 59. 29.100 / 59. 29.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 46.101 / 8. 46.101
libswscale 6. 8.101 / 6. 8.101
libswresample 4. 8.100 / 4. 8.100
libpostproc 56. 7.100 / 56. 7.100
[...]
x265 [info]: HEVC encoder version 3.5+39-7c7ea0a4b
x265 [info]: build info [Windows][GCC 12.1.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX
FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 32 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 5 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 3
x265 [info]: Keyframe min / max / scenecut / bias : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 0 / 0
x265 [info]: References / ref-limit cu / depth : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-28.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: strong-intra-smoothing lslices=6
Output #0, mp4, to 'output-ffmpeg-x265.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: dashmp42mp41iso6
encoder : Lavf59.29.100
Stream #0:0(und): Video: hevc (hev1 / 0x31766568), yuv420p(tv, bt709,
progressive), 1920x1080, q=2-31, 25 fps, 12800 tbn (default)
[...]
frame=47668 fps=149 q=36.0 Lsize= 68921kB time=00:31:46.66 bitrate=
296.1kbits/s speed=5.95x
video:37629kB audio:29729kB subtitle:0kB other streams:0kB global
headers:2kB muxing overhead: 2.320609%
x265 [info]: frame I: 191, Avg QP:25.97 kb/s: 15697.02
x265 [info]: frame P: 11608, Avg QP:32.58 kb/s: 314.05
x265 [info]: frame B: 35869, Avg QP:35.71 kb/s: 28.56
x265 [info]: consecutive B-frames: 6.3% 7.3% 15.7% 17.4% 53.3%
encoded 47668 frames in 320.57s (148.70 fps), 160.87 kb/s, Avg QP:34.91
Result is about 70MB (161kb/s data speed, 289kb/s full trans speed; 127kb/s
for music)
Anybody have an idea why?
More information about the ffmpeg-user
mailing list