viernes, 13 de mayo de 2016

Save storage transcoding your videos with HEVC / H.265



If you have ffmpeg installed this is the command:
ffmpeg -i input -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k output.mp4
If you need ffmpeg use this links: OSX / Windows 10 / Ubuntu / Debian / Mint / CentOS / RHEL / Fedora / Raspberry Pi (Raspbian) / Android / Other

H.265 (also known as HEVC) offers 50-75% more compression efficiency compared to H.264 video, while retaining the same visual quality. ffmpeg has support for HEVC encoding using the x265 encoder. Note: libx265 is under heavy development. The API may change.


In order to obtain a copy of ffmpeg with libx265 support, you need to build it yourself, adding the --enable-libx265 configuration flag, with x265 being installed on your system.
You can also download a static build, all of which bundle libx265.

 Encoding

Similar to x264, the x265 encoder has multiple rate control algorithms, including:
  • 1-pass constant bitrate (by setting -b:v)
  • 2-pass constant bitrate (see H.264#twopass)
  • Constant Rate Factor (CRF)

Constant Rate Factor (CRF)


Use this mode if you want to retain good visual quality and don't care about the exact bitrate or filesize of the encoded file. The mode works exactly the same as in x264, so please read the H.264 guide for more info.
In this example, we will use the following settings:
  • default CRF of 28. The CRF of 28 should visually correspond to libx264 video at CRF 23, but result in about half the file size.
  • medium preset. The preset determines how fast the encoding process will be – at the expense of compression efficiency. Put differently, if you choose ultrafast, the encoding process is going to run fast, but the file size will be larger when compared to medium. The visual quality will be the same. Valid presets are ultrafastsuperfastveryfastfasterfastmediumslowslowerveryslow and placebo.
  • AAC audio at 128 kBit/s. This uses the ffmpeg-internal encoder, but under AAC you will find info about more options.
 General (CRF=28, audio: aac, 128kbps)
ffmpeg -i input -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k output.mp4


Lowest compression (CRF=1, audio: aac, 128kbps)
ffmpeg -i input -c:v libx265 -preset medium -x265-params crf=1-c:a aac -strict experimental -b:a 128k output.mp4



 Lossless: 
ffmpeg -i INPUT -c:v libx265 -preset medium -x265-params lossless=1 OUTPUT

Generally, options are passed to x265 with the -x265-params argument. For fine-tuning the encoding process, you can therefore pass any option that is listed in the x265 documentation. Keep in mind that fine-tuning any of the options is generally not necessary, unless you absolutely know what you need to change.


Extracting i-frames for comparison:


ffmpeg -i INPUT -y -f image2 OUTPUTfolder/OUTPUT_%04d.png

No hay comentarios:

Publicar un comentario