PDA

View Full Version : How to use ffmpeg libx265 12bit?


tuanden0
11th September 2018, 07:26
Hello everyone,

I tried to use many way to encode x265_12bit using ffmpeg but the output still 10bit.

I use ffmpeg static 4.0.2 here: https://ffmpeg.zeranoe.com/builds/
My script:
"C:\Program Files (x86)\VapourSynth\core64\vspipe.exe" --y4m "%~dpn1.vpy" - | "%~dp0Tools\ffmpeg.exe" -y -hwaccel cuvid -i - -c:v libx265 -crf %crf%
-c:v hevc_nvenc -x265-params "profile=main12:preset=slow:deblock=1;-1:output-depth=12:aq-mode=3"
-pix_fmt yuv420p12le "%~dpn1.hevc"

Can someone help me? :o

Blue_MiSfit
11th September 2018, 07:37
Try moving pix_fmt yuv420p12le to right after your `-i -` argument.

Not sure if the zeranoe build supports 12 bit, though I know it does support 8/10 bit last I checked.

Also not sure if your syntax for deblock is correct

Finally, why do you have both -c:v libx265 and -c:v hevc_nvenc ? That may be the issue ;)

tuanden0
11th September 2018, 08:00
Try moving pix_fmt yuv420p12le to right after your `-i -` argument.

Not sure if the zeranoe build supports 12 bit, though I know it does support 8/10 bit last I checked.

Also not sure if your syntax for deblock is correct

Finally, why do you have both -c:v libx265 and -c:v hevc_nvenc ? That may be the issue ;)

Thank you for reply
I move -pix_fmt yuv420p12le to right after `-i -` but output still 10bit.

Could you give me the bin of ffmpeg that support 12bit.

I changed ';' to ':' of deblock and ffmpeg still work.

I remove -c:v libx265 and re-encode but the output still 10bit.

Ma
11th September 2018, 08:50
Could you give me the bin of ffmpeg that support 12bit.

You can use ffmpeg binary compiled by zeranoe (with x265 8bit+10bit). For 12bit encoding you need only libx265_main12.dll file in version like x265 inside ffmpeg. Please put ffmpeg.exe and libx265_main12.dll in one folder.

libx265_main12.dll you can download for example from www.msystem.waw.pl/x265 (inside 7z archives with x265)

tuanden0
11th September 2018, 09:56
You can use ffmpeg binary compiled by zeranoe (with x265 8bit+10bit). For 12bit encoding you need only libx265_main12.dll file in version like x265 inside ffmpeg. Please put ffmpeg.exe and libx265_main12.dll in one folder.

libx265_main12.dll you can download for example from www.msystem.waw.pl/x265 (inside 7z archives with x265)
:thanks:
I download libx265_main12.dll and put it in same folder with ffmpeg but the output still 10bit ?_?

Ma
11th September 2018, 10:13
Are you using libx265? In my system it looks like this:
f:\speed\2.8+66>ffmpeg -i ../1920x800-hob.y4m -c:v libx265 -crf 20 -pix_fmt yuv420p out8.hevc
ffmpeg version N-91836-g4cfb01d6ae Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20180813
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 19.100 / 56. 19.100
libavcodec 58. 28.100 / 58. 28.100
libavformat 58. 18.100 / 58. 18.100
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 27.100 / 7. 27.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, yuv4mpegpipe, from '../1920x800-hob.y4m':
Duration: 00:00:31.28, start: 0.000000, bitrate: 441927 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.8+66-88ee12651e30
x265 [info]: build info [Windows][GCC 8.2.1][64 bit] 8bit+10bit
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 12 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(13 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 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 23 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-20.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=5 deblock sao
Output #0, hevc, to 'out8.hevc':
Metadata:
encoder : Lavf58.18.100
Stream #0:0: Video: hevc (libx265), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 23.98 fps, 23.98 tbn, 23.98 tbc
Metadata:
encoder : Lavc58.28.100 libx265
frame= 750 fps= 25 q=-0.0 Lsize= 29599kB time=00:00:31.19 bitrate=7772.1kbits/s speed=1.05x
video:29599kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
x265 [info]: frame I: 9, Avg QP:19.87 kb/s: 58820.56
x265 [info]: frame P: 195, Avg QP:22.33 kb/s: 19030.20
x265 [info]: frame B: 546, Avg QP:28.38 kb/s: 2874.08
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 5.9% 8.3% 13.7% 56.4% 15.7%

encoded 750 frames in 29.65s (25.29 fps), 7746.03 kb/s, Avg QP:26.71

f:\speed\2.8+66>ffmpeg -i ../1920x800-hob.y4m -c:v libx265 -crf 20 -pix_fmt yuv420p12 out12.hevc
ffmpeg version N-91836-g4cfb01d6ae Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20180813
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 19.100 / 56. 19.100
libavcodec 58. 28.100 / 58. 28.100
libavformat 58. 18.100 / 58. 18.100
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 27.100 / 7. 27.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, yuv4mpegpipe, from '../1920x800-hob.y4m':
Duration: 00:00:31.28, start: 0.000000, bitrate: 441927 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.8+66-88ee12651e30
x265 [info]: build info [Windows][MSVC 1900][64 bit] 12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main 12 profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(13 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 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 23 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-20.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=5 deblock sao
Output #0, hevc, to 'out12.hevc':
Metadata:
encoder : Lavf58.18.100
Stream #0:0: Video: hevc (libx265), yuv420p12le, 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 23.98 fps, 23.98 tbn, 23.98 tbc
Metadata:
encoder : Lavc58.28.100 libx265
frame= 750 fps= 21 q=-0.0 Lsize= 27132kB time=00:00:31.19 bitrate=7124.3kbits/s speed=0.853x
video:27132kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
x265 [info]: frame I: 9, Avg QP:20.82 kb/s: 51591.05
x265 [info]: frame P: 190, Avg QP:22.85 kb/s: 16998.40
x265 [info]: frame B: 551, Avg QP:28.25 kb/s: 2959.98
x265 [info]: Weighted P-Frames: Y:1.1% UV:1.1%
x265 [info]: consecutive B-frames: 6.5% 5.0% 12.1% 57.8% 18.6%

encoded 750 frames in 36.55s (20.52 fps), 7099.95 kb/s, Avg QP:26.79

tuanden0
11th September 2018, 10:26
@Ma: I did it, I using libx265_main10 instead of main12. My mistake, Thank you!

Iron_Mike
27th February 2019, 08:02
cannot get 12-bit encoding to work on Zeranoe's build... copied "libx265_main12.dll" into the same folder as ffmpeg... get this message on run:

Incompatible pixel format 'yuv444p12le' for codec 'libx265', auto-selecting format 'yuv444p10le'

so it is not using the "libx265_main12.dll"... any advice ?

Thanks.

Ma
27th February 2019, 19:39
ffmpeg build "ffmpeg-20190225-f948082-win64-static.zip", libx265_main12.dll from "x265-3.0_Au+7-cb3e172_vs2015-AVX2.7z":

ffmpeg -i ../1920x800-hob.y4m -pix_fmt yuv444p12 w12-444.hevc
ffmpeg version N-93252-gf948082e5f Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.102 / 58. 47.102
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, yuv4mpegpipe, from '../1920x800-hob.y4m':
Duration: 00:00:31.28, start: 0.000000, bitrate: 441927 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 3.0_Au+7-cb3e172a5f51
x265 [info]: build info [Windows][MSVC 1900][64 bit] 12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main 4:4:4 12 profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(13 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 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 23 / 250 / 40 / 5.00
x265 [info]: Cb/Cr QP Offset : 6 / 6
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / 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 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=5 deblock sao
Output #0, hevc, to 'w12-444.hevc':
Metadata:
encoder : Lavf58.26.101
Stream #0:0: Video: hevc (libx265), yuv444p12le, 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 23.98 fps, 23.98 tbn, 23.98 tbc
Metadata:
encoder : Lavc58.47.102 libx265
frame= 750 fps= 19 q=-0.0 Lsize= 12707kB time=00:00:31.19 bitrate=3336.6kbits/s speed=0.771x
video:12707kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
x265 [info]: frame I: 9, Avg QP:27.16 kb/s: 29400.04
x265 [info]: frame P: 190, Avg QP:29.34 kb/s: 7912.31
x265 [info]: frame B: 551, Avg QP:34.58 kb/s: 1313.41
x265 [info]: Weighted P-Frames: Y:1.1% UV:1.1%
x265 [info]: consecutive B-frames: 6.5% 5.0% 12.1% 57.8% 18.6%

encoded 750 frames in 40.43s (18.55 fps), 3322.17 kb/s, Avg QP:33.17

Encoded file is yuv444p12 and is watchable.

For using ffmpeg/x265 with libx265_main*.dll it is important to use the same X265_BUILD -- now it is 170. If you use ffmpeg with x265 inside and you find in ffmpeg.exe string "x265_api_get_" just read the number after -- now it is "x265_api_get_170", so exactly the same function should be in libx265_main12.dll.