Log in

View Full Version : HEVC to Animated WEBP


jay123210599
29th September 2024, 00:48
How do I convert a HEVC video to a lossless animated webp file, and make the output have the same colors as the input?

Video information:
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Format Range@L4@Main
Codec ID : V_MPEGH/ISO/HEVC
Bit rate : 10.1 Mb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:4:4
Bit depth : 10 bits
Bits/(Pixel*Frame) : 0.203
Stream size : 1.67 GiB (87%)
Title : BDRip by DJATOM
Writing library : x265 3.0_Au+22-feec4bdf9866:[DJATOM's Mod][Linux][GCC 6.3.0][64 bit] 10bit
Encoding settings : cpuid=1111039 / frame-threads=2 / numa-pools= / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / csv / csv-log-level=2 / input-csp=3 / input-res=1920x1080 / interlace=0 / total-frames=34120 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / open-gop / min-keyint=23 / keyint=240 / gop-lookahead=0 / bframes=9 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=6 / scenecut=40 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=2 / tu-intra-depth=2 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / limit-modes / me=2 / subme=5 / merange=48 / temporal-mvp / weightp / weightb / no-analyze-src-pics / deblock=1:-1 / no-sao / no-sao-non-deblock / rd=4 / no-early-skip / no-rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=4.00 / no-rd-refine / no-lossless / cbqpoffs=4 / crqpoffs=4 / rc=crf / crf=15.0 / qcomp=0.72 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=3 / aq-strength=0.85 / no-cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=0 / display-window=0 / max-cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr / no-hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=0 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / hevc-aq / no-svt / qp-adaptation-range=2.00
Language : Japanese
Default : Yes
Forced : No
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Z2697
29th September 2024, 01:07
Not very related to HEVC
ffmpeg -i input -c:v libwebp_anim -lossless 1 output.webp

Lossless webp only supports ARGB so ffmpeg needs to convert your YUV video to ARGB first, luckily you have 4:4:4 which perhaps saves some trouble.
FFmpeg automately does the conversion for you, but it often not very favorable, converting from 10bit yuv to rgb result in more banding than it shoud be, even when dither is enabled by default, and it may stick with default matrix BT.601.
If you want control over this conversion you can use -vf zscale=min=709[:d=ordered],format=gbrap , why zscale? Because if you use scale(swscale) then it's the same as automated.

BUT WHY???
Explain it to me or you will make me unable to sleep tonight

jay123210599
29th September 2024, 12:31
Not very related to HEVC
ffmpeg -i input -c:v libwebp_anim -lossless 1 output.webp

Lossless webp only supports ARGB so ffmpeg needs to convert your YUV video to ARGB first, luckily you have 4:4:4 which perhaps saves some trouble.
FFmpeg automately does the conversion for you, but it often not very favorable, converting from 10bit yuv to rgb result in more banding than it shoud be, even when dither is enabled by default, and it may stick with default matrix BT.601.
If you want control over this conversion you can use -vf zscale=min=709[:d=ordered],format=gbrap , why zscale? Because if you use scale(swscale) then it's the same as automated.

BUT WHY???
Explain it to me or you will make me unable to sleep tonight

Just thought it was a better option for lower file sizes than APNGs while maintaining perfect quality.