savsanta

GoogleVP9-and -AV1EncodingRecDoc

Jan 13th, 2021 (edited)
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.80 KB | None | 0 0
  1. Examples given are for 2-pass VP9 encoding with FFMpeg. Ensure that your FFMpeg has been built with libvpx support.
  2.  
  3.  
  4. VOD Recommended Settings
  5.  
  6. ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 8 -speed 4 \
  7.  
  8. -tile-columns 6 -frame-parallel 1 \
  9.  
  10. -an -f webm /dev/null
  11.  
  12.  
  13. ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 8 -speed 1 \
  14.  
  15. -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  16.  
  17. -c:a libopus -b:a 64k -f webm out.webm
  18.  
  19.  
  20. c:v libvpx-vp9 tells FFmpeg to encode the video in VP9.
  21.  
  22. c:a libopus tells FFmpeg to encode the audio in Opus.
  23.  
  24. b:v 1000K tells FFmpeg to encode the video with a target of 1000 kilobits.
  25.  
  26. b:a 64k tells FFmpeg to encode the audio with a target of 64 kilobits.
  27.  
  28. Most of the current VP9 decoders use tile-based, multi-threaded decoding. In order for the decoders to take advantage of multiple cores, the encoder must set tile-columns and frame-parallel.
  29.  
  30. Setting auto-alt-ref and lag-in-frames >= 12 will turn on VP9's alt-ref frames, a VP9 feature that enhances quality.
  31.  
  32. speed 4 tells VP9 to encode really fast, sacrificing quality. Useful to speed up the first pass.
  33.  
  34. speed 1 is a good speed vs. quality compromise. Produces output quality typically very close to speed 0, but usually encodes much faster.
  35.  
  36. Multi-threaded encoding may be used if -threads > 1 and -tile-columns > 0.
  37.  
  38.  
  39. DASH Recommended Settings
  40.  
  41. See http://wiki.webmproject.org/adaptive-streaming/instructions-to-playback-adaptive-webm-using-dash for WebM DASH settings.
  42.  
  43. Best Quality (Slowest) Recommended Settings
  44.  
  45. ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 1 -speed 4 \
  46.  
  47. -tile-columns 0 -frame-parallel 0 \
  48.  
  49. -g 9999 -aq-mode 0 -an -f webm /dev/null
  50.  
  51.  
  52.  
  53. ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \
  54.  
  55. -tile-columns 0 -frame-parallel 0 -auto-alt-ref 1 -lag-in-frames 25 \
  56.  
  57. -g 9999 -aq-mode 0 -c:a libopus -b:a 64k -f webm out.webm
  58.  
  59.  
  60. tile-columns 0, frame-parallel 0: Turning off tile-columns and frame-parallel should give a small bump in quality, but will most likely hamper decode performance severely.
  61.  
  62. Constant Quality Recommended Settings
  63.  
  64. Objective is to achieve a constant (perceptual) quality level without regard to bitrate.
  65.  
  66. (Note that Constant Quality differs from Constrained Quality, described below.)
  67.  
  68. ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 0 -crf 33 -threads 8 -speed 4 \
  69.  
  70. -tile-columns 6 -frame-parallel 1 \
  71.  
  72. -an -f webm /dev/null
  73.  
  74.  
  75. ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 0 -crf 33 -threads 8 -speed 2 \
  76.  
  77. -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  78.  
  79. -c:a libopus -b:a 64k -f webm out.webm
  80.  
  81.  
  82. crf is the quality value (0-63 for VP9). To trigger this mode, you must use a combination of crf <q-value> and b:v 0. bv MUST be 0.
  83.  
  84. Constrained Quality Recommended Settings
  85.  
  86. Objective is to achieve a constant (perceptual) quality level as long as the bitrate achieved is below a specified upper bound. Constrained Quality is useful for bulk encoding large sets of videos in a generally consistent fashion.
  87.  
  88. ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1400K -crf 23 -threads 8 -speed 4 \
  89.  
  90. -tile-columns 6 -frame-parallel 1 \
  91.  
  92. -an -f webm /dev/null
  93.  
  94.  
  95. ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1400K -crf 23 -threads 8 -speed 2 \
  96.  
  97. -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  98.  
  99. -c:a libopus -b:a 64k -f webm out.webm
  100.  
  101.  
  102. The quality desired is provided as the crf <q-value> parameter and the bitrate upper bound is provided as the b:v <bitrate> parameter, where bitrate MUST be non-zero.
  103.  
  104. Both crf <q-value> and b:v <bitrate> MUST be provided. In this mode, bitrate control will kick in for difficult videos, where the quality specified cannot be achieved within the given bitrate.
  105.  
  106. For easy videos, this mode behaves exactly like the constant quality mode, and the actual bitrate achieved can be much lower than the specified bitrate in the b:v parameter.
  107.  
  108. One caveat in FFMpeg is that if you do not provide the b:v parameter, FFMpeg will assume a default target bitrate of 256K -- so the constrained quality mode will be triggered with a potentially very low target bitrate.
  109.  
  110. ==============================================================================
  111. ==============================================================================
  112. ==============================================================================
  113. LibAOM Encoding (an early not yet generally avialable codec)
  114.  
  115.  
  116.  
  117. wiki:
  118. Encode
  119. /
  120. AV1
  121.  
  122. Up-vote+1Down-voteUpStart PageIndexHistory
  123.  
  124. libaom AV1 Encoding Guide
  125.  
  126. Contents
  127.  
  128. Constant Quality
  129. Constrained Quality
  130. Two-Pass
  131. Average Bitrate (ABR)
  132. Controlling Speed / Quality
  133. HDR
  134. More Info
  135.  
  136. libaom-av1 is the AOMedia video encoder for ​AV1, an open source & royalty-free video codec. libaom-av1 can save about 30% bitrate compared to VP9 and H.265 / HEVC, and about 50% over H.264, while retaining the same visual quality.
  137.  
  138. To install FFmpeg with support for libaom-av1, look at the Compilation Guides and compile FFmpeg with the --enable-libaom option.
  139.  
  140. libaom offers the following rate-control modes which determine the quality and file size obtained:
  141.  
  142. Constant quality
  143. Constrained quality
  144. 2-pass average bitrate
  145. 1-pass average bitrate
  146.  
  147. For a list of options, run ffmpeg -h encoder=libaom-av1.
  148.  
  149. Note: Users of libaom older than version 2.0.0 will need to add -strict experimental (or the alias -strict -2).
  150. Constant Quality
  151.  
  152. libaom-av1 has a constant quality (CQ) mode (like CRF in x264 and x265) which will ensure that every frame gets the number of bits it deserves to achieve a certain (perceptual) quality level, rather than encoding each frame to meet a bit rate target. This results in better overall quality. If you do not need to achieve a fixed target file size, this should be your method of choice.
  153.  
  154. To trigger this mode, you must use a combination of -crf and -b:v 0. -b:v MUST be 0.
  155.  
  156. ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 0 av1_test.mkv
  157.  
  158. The CRF value can be from 0–63. Lower values mean better quality and greater file size.
  159. Constrained Quality
  160.  
  161. libaom-av1 also has a constrained quality (CQ) mode that will ensure that a constant (perceptual) quality is reached while keeping the bitrate below a specified upper bound or within a certain bound. This method is useful for bulk encoding videos in a generally consistent fashion.
  162.  
  163. ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 2000k output.mkv
  164.  
  165. The quality is determined by the -crf, and the bitrate limit by the -b:v where the bitrate MUST be non-zero.
  166.  
  167. You can also specify a minimum and maximum bitrate instead of a quality target:
  168.  
  169. ffmpeg -i input.mp4 -c:v libaom-av1 -minrate 500k -b:v 2000k -maxrate 2500k output.mp4
  170.  
  171. Note: When muxing into MP4, you may want to add -movflags +faststart to the output parameters if the intended use for the resulting file is streaming.
  172. Two-Pass
  173.  
  174. In order to create more efficient encodes when a particular target bitrate should be reached, you should choose two-pass encoding. For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:
  175.  
  176. In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively.
  177. In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
  178. In pass 1, you can leave audio out by specifying -an.
  179.  
  180. ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 1 -an -f null /dev/null && \
  181. ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 2 -c:a libopus output.mkv
  182.  
  183. Note: Windows users should use NUL instead of /dev/null and ^ instead of \.
  184. Average Bitrate (ABR)
  185.  
  186. libaom-av1 also offers a simple "Average Bitrate" or "Target Bitrate" mode. In this mode, it will simply try to reach the specified bit rate on average, e.g. 2 MBit/s.
  187.  
  188. ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M output.mkv
  189.  
  190. Use this option only if file size and encoding time are more important factors than quality alone. Otherwise, use one of the other rate control methods described above.
  191. Controlling Speed / Quality
  192.  
  193. -cpu-used sets how efficient the compression will be. Default is 1. Lower values mean slower encoding with better quality, and vice-versa.
  194.  
  195. -row-mt 1 enables row-based multi-threading which maximizes CPU usage. To enable fast decoding performance, also add tiles (i.e. -tiles 4x1 or -tiles 2x2 for 4 tiles). Enabling row-mt is only faster when the CPU has more threads than the number of encoded tiles.
  196. HDR
  197.  
  198. When encoding in HDR it's necessary to pass through color information; -colorspace, -color_trc and -color_primaries. For example, Youtube HDR uses
  199.  
  200. -colorspace bt2020nc -color_trc smpte2084 -color_primaries bt2020
  201.  
  202. More Info
  203.  
  204. More info about AV1 can be found here:
  205.  
  206. ​Nwgat's AOMedia's AV1 Codec Overview
Add Comment
Please, Sign In to add comment