sparktank

FFMPEG and lossless ffvhuff codec

Mar 18th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.09 KB | None | 0 0
  1. ========================================================================================================
  2. ========================================================================================================
  3. Encoder ffvhuff [Huffyuv FFmpeg variant]:
  4. General capabilities: threads
  5. Threading capabilities: frame
  6.  
  7. Supported pixel formats:
  8. yuv420p yuv422p yuv444p
  9. (implied 8-bit video; YV12/YV16*/YV24 planars)
  10. (* avoid ever using YUY2. Avisynth updated for YV16 in place of YUY2; as YUY2 requires resampling))
  11.  
  12. yuv411p yuv410p yuv440p
  13. gbrp gbrp9le gbrp10le gbrp12le gbrp14le
  14. gray gray16le
  15. yuva420p yuva422p yuva444p
  16. gbrap
  17. ya8
  18. (rarely needed colorspaces; maybe just grayscale videos)
  19. ("le" is "Little Endian")
  20.  
  21. (9-bit through 16-bit video; YV12/YV16*/YV24 planars)
  22. (* avoid ever using YUY2. Avisynth updated for YV16 in place of YUY2; as YUY2 requires resampling)
  23. yuv420p9le yuv420p10le yuv420p12le yuv420p14le yuv420p16le
  24. yuv422p9le yuv422p10le yuv422p12le yuv422p14le yuv422p16le
  25. yuv444p9le yuv444p10le yuv444p12le yuv444p14le yuv444p16le
  26. (Avisynth/L-SmashWorks works best with 10le or 16le if greater than 8-bit. Import xyz12le (12-bit) as 16-bit; does not increase quality, just maintains precision)
  27.  
  28. yuva420p9le yuva420p10le yuva420p16le
  29. yuva422p9le yuva422p10le yuva422p16le
  30. yuva444p9le yuva444p10le yuva444p16le
  31. (alpha variants rarely needed)
  32.  
  33. rgb24 bgra
  34. (bgra rarely needed)
  35.  
  36. ffvhuff AVOptions:
  37. -non_deterministic <boolean> E..V.... Allow multithreading for e.g. context=1 at the expense of determinism (default true)
  38. -pred <int> E..V.... Prediction method (from 0 to 2) (default left)
  39. left E..V....
  40. plane E..V....
  41. median E..V....
  42. -context <int> E..V.... Set per-frame huffman tables (from 0 to 1) (default 0)
  43. ========================================================================================================
  44. ========================================================================================================
  45. FFMPEG usage example:
  46. "C:\Apps\VidEnc\ffmpeg_64\ffmpeg.exe" -stats -report -i "VIDEO.mxf" -map 0:0 -map_metadata -1 -pix_fmt yuv444p16le -vcodec ffvhuff "OUTPUT-ffvhuff-yuv444p16le.avi"
  47. ========================================================================================================
  48. FFProbe info on VIDEO.mxf (2K DCP)
  49. Stream #0:0: Video: jpeg2000 (JPEG 2000 digital cinema 2K), xyz12le, 1998x1080, SAR 1:1 DAR 37:20, 24 tbr, 24 tbn, 24 tbc
  50. xyz colorspace, 12-bit video, little endian
  51. ========================================================================================================
  52. ========================================================================================================
  53. FFMPEG correctly converts colorspace from XYZ to RGB or YUV planars.
  54. Stand-alone hardware players, YUV is most compatible, so use a YUV planar colorspace.
  55. XYZ -> RGB -> YV24
  56. But, YV24 is not very compatible, so YV12.
  57. XYZ -> RGB -> YV12
  58. in terms of quality...
  59. XYZ -> RGB -> YV24 -> YV16 -> YV12
  60. RGB and YV24 colorspaces would be for PC only, streaming untested.
  61.  
  62. Resulting lossless .avi will be YV24 (4:4:4 chroma subsampling) and 16-bit video.
  63. Use L-SmashWorks to index and load video in Avisynth as 16-bit (set "stacked=true" to get actual high bit-depth).
  64. Use "Dither" package to crop and resize in (stacked, not interleaved) 16-bit processing and covnert to YV12 and dither down to 8-bit video.
  65. ========================================================================================================
  66. ========================================================================================================
  67. Avisynth script to load OUTPUT-ffvhuff-yuv444p16le.avi
  68. ========================================================================================================
  69. LoadPlugin ("D:\AVS\L-SMASH-Works\L-SMASH-Works-r875-20160202-32bit\AviSynth\LSMASHSource.dll")
  70. LWLibavVideoSource ("E:\Temp\LegoBatman\LegoBatmanMovie_TLR-ffvhuff-yuv444p16le.avi", stacked = true, format = "YUV444P16")
  71. #Trim(193,2184) # Frames with video data only
  72. Trim (191,2209) # Crop taking audio into consideration
  73. ### audio exceeds total number of frames with video data, black frames must be included to keep everything in sync
  74. Dither_Crop16 (0, 122, -0, -122)
  75. Dither_convert_yuv_to_rgb (lsb_in=true, matrix="709", noring=true, output="rgb48y", tv_range=false, chromak="spline36")
  76. ### Now it's in fancy new RGB colorspace **use just for dither package inside Avsiynth!**
  77. Dither_y_gamma_to_linear (tv_range_in=false, tv_range_out=false, curve="709", u=1, v=1, sigmoid=true)
  78. ### Now in linear light, I think Y8 colorspace. No chroma here
  79. #Dither_resize16nr (2048, 858, kernel="spline36", u=1, v=1) #2.387:1
  80. Dither_resize16nr (2048, 856, kernel="spline36", u=1, v=1) #2.393:1 ## Closest to 2.39:1 in modular 2 resize
  81. ### illegal resize using modular 1 to get 2028x857 for absolute 2.39:1 would require RGB conversion
  82. Dither_y_linear_to_gamma (tv_range_in=false, tv_range_out=false, curve="709", u=1, v=1, sigmoid=true)
  83. Dither_convert_rgb_to_yuv (
  84. \ SelectEvery (3, 0), SelectEvery (3, 1), SelectEvery (3, 2),
  85. \ matrix="709", noring=true, output="YV12", tv_range=false, chromak="spline36",
  86. \ lsb=true)
  87. DitherPost (mode=7)
  88. ========================================================================================================
  89. ========================================================================================================
  90. Before encoding with x264 [kMod - built by komisar], I saved the 8bit/YV12 to a lossless video using UtVideo Codec.
  91. When I go to encode the 10bit/YV24, I'll need to pipe directly from .avs script to x264.exe to transfer all data correctly.
  92. The extra step in making a 10-bit lossless intermediate is too much to bother with so encoding overnight for the 10-bit x264 encode from .avs is more sensible. The encoding fps rate will drop drastically. Less than .50fps for encoding.
  93. ========================================================================================================
  94. ========================================================================================================
  95. x264 batch script for the 8bit encode:
  96. "D:\AVS\avs4x26x\avs4x26x.exe" --x26x-binary "C:\Apps\VidEnc\x264_kMod\k8_64.exe" --log-file "E:\Work\Encodes\LegoBatmanMovie_TLR-8bit-YV12-2K-v2.txt" --log-file-level 2 --quiet --no-progress --demuxer raw --input-depth 8 --input-res 2048x856 --fps 24/1 --thread-input --threads 3 --crf 14 --preset placebo --profile high --level 4.1 --merange 32 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --input-csp i420 --output-csp i420 --no-dct-decimate --no-mbtree --no-mixed-refs --aq-strength 0.85 --deblock -3:-3 --aq-mode 3 -o "E:\Work\Encodes\LegoBatmanMovie_TLR-8bit-YV12-2K-v2.mkv" "D:\Temp\LegoBatmanMovie_TLR-8bit-YV12-2K.avs"
  97.  
  98. increased crf to 14 since 2K. tried CRF=16 and there was banding
  99. increased merange to 32, since >1080
  100. added --no-dct-decimate
  101. added --no-mbtree (significantly reduces chances of banding during fading/dark scenes)
  102. added --no-mixed-refs
  103. removed --no-fast-pskip (as it is included in the "placebo" preset, otherwise add if less than "placebo")
  104. lowered default --aq-strength
  105. lowered default deblock
  106. used --aq-mode 3 (for more bias towards darker screens)
  107.  
  108. Nearly transparent encode. Maybe tweak ip/pb ratios. Maybe try different --aq-strength values (0.6-.95; but not 1.0). Maybe increase CRF to 13.
  109. ========================================================================================================
  110. ========================================================================================================
  111. x264 r2556 kMod log:
  112. x264 [info]: 2048x856p 0:0 @ 24/1 fps (cfr)
  113. x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
  114. x264 [info]: profile High, level 4.1
  115. x264 [info]: cabac=1 ref=4 deblock=1:-3:-3 analyse=0x3:0x133 me=tesa subme=11 psy=1 fade_compensate=0.00 psy_rd=1.00:0.00 mixed_ref=0 me_range=32 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=0 interlaced=0 bluray_compat=0 constrained_intra=0 fgo=0 bframes=16 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=14.0000 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 pb_ratio=1.30 aq=3:0.85
  116. x264 [info]: frame I:20 Avg QP: 8.76 size:312321
  117. x264 [info]: frame P:415 Avg QP:11.32 size:181596
  118. x264 [info]: frame B:1584 Avg QP:12.89 size: 80600
  119. x264 [info]: consecutive B-frames: 3.1% 2.3% 6.7% 20.6% 14.1% 21.7% 7.6% 7.5% 4.0% 3.0% 1.1% 1.8% 1.3% 2.1% 1.5% 0.8% 0.8%
  120. x264 [info]: mb I I16..4: 11.2% 70.2% 18.6%
  121. x264 [info]: mb P I16..4: 1.4% 24.9% 3.2% P16..4: 22.0% 26.9% 11.6% 7.2% 0.8% skip: 2.0%
  122. x264 [info]: mb B I16..4: 0.2% 5.5% 0.3% B16..8: 27.2% 29.4% 10.9% direct:11.6% skip:14.8% L0:44.2% L1:43.2% BI:12.6%
  123. x264 [info]: 8x8 transform intra:85.8% inter:35.9%
  124. x264 [info]: direct mvs spatial:99.8% temporal:0.2%
  125. x264 [info]: coded y,uvDC,uvAC intra: 95.2% 97.6% 96.0% inter: 45.6% 52.8% 35.5%
  126. x264 [info]: i16 v,h,dc,p: 13% 9% 18% 60%
  127. x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 12% 16% 8% 9% 9% 9% 10% 13%
  128. x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 10% 8% 10% 13% 12% 12% 10% 13%
  129. x264 [info]: i8c dc,h,v,p: 51% 19% 14% 16%
  130. x264 [info]: Weighted P-Frames: Y:25.1% UV:23.9%
  131. x264 [info]: ref P L0: 48.0% 2.4% 26.0% 18.4% 5.0% 0.2%
  132. x264 [info]: ref B L0: 75.5% 19.7% 4.8%
  133. x264 [info]: ref B L1: 84.4% 15.6%
  134. x264 [info]: kb/s:19901.71
  135. x264 [info]: encoded 2019 frames, 1.15 fps, 19901.79 kb/s, duration 0:29:10.02
  136. ========================================================================================================
  137.  
  138. https://ffmpeg.zeranoe.com/builds/
  139. http://avisynth.nl/index.php/LSMASHSource/LSMASHVideoSource
  140. http://avisynth.nl/index.php/Dither
  141. http://www.videohelp.com/software/Ut-Video-Codec-Suite
  142. http://forum.doom9.org/showthread.php?t=162656 (avs4x26x for piping 32-bit Avisynth script to 64-bit x264.exe)
  143. http://komisar.gin.by/ (for better x264 patches instead of vanilla builds with handbrake, etc)
Add Comment
Please, Sign In to add comment