[FFmpeg-user] Reencoding from H.264 to H.265
Sven C. Dack
sven.c.dack at sky.com
Fri Sep 2 09:50:03 EEST 2016
Hello,
it seems my first e-mail got lost, which is why I am writing a second one. If
there is an issue with the moderation then please apologize for the duplicate...
On the subject... I've been doing just that. Transcoding H.264 videos into
H.265, scaling these down to 480p and reducing the bitrate to about 1mbit/s.
Most important for this process aren't so much the encoder settings, but how the
downscaling is performed. Because the original data was compressed with the help
of Discrete Cosine Transformations (DCT) does one need to preserve the typical
shape of these transformations as close as possible. That way will the encoder
have less problems to do the same in the transcoding. If the wrong interpolation
algorithm is being used then this will deform the original DCT-shaped data and
further DCTs will add a significant amount of artificial information to the data
stream.
Using the same quality settings are there significant differences in the video
file sizes for different scaling algorithms. Here is a picture which shows the
scaling algorithms of the CUDA NPP filter "scale_npp" with NVENC at -qmax 20 and
-qmax 24 including the file size of the output:
http://i.imgur.com/c7hzoae.png
It shows that using super-sampling at "-qmax 20" needs about as much space as a
lanczos filter at "-qmax 24" (the higher the -qmax the lower the quality). It's
possible to think with lanczos would you get a sharper picture, but it will cost
you several levels of quality in return. Further can one see how all but
super-sampling add aliasing artefacts to the image. Some even add colour errors
to the image. A still image may look good (or perhaps more interesting), but
when watching the video do these artefacts turn into moire patterns and pixel
flickering when a camera pans across a scene.
I've seen people using and recommending lanczos and cubic interpolations, and
these are good filters for most purposes, however it shows that these are even
worse than a simple linear interpolation algorithm when it comes to transcoding.
If you keep this in mind then you can safely transcode and downscale old H.264
videos into H.265.
Upscaling the video before transcoding makes no sense to me and so I've never
tested it.It's better to zoom the video in the video player and use
post-processing filters as needed.
If no scaling is performed then one can do the transcoding completely on an
Nvidia GPU by using the CUVID decoders and NVENC encoders. Here an example:
ffmpeg -v:c vp9_cuvid -i U-HD-2160p.webm -v:c hevc_nvenc -y out-2160p.mkv
This transcodes an UltraHD WebM video with VP9 encoding into an H.265/HEVC video
in a Matroska container. An Nvidia GTX 960 will do this at about 52fp/s with the
encoder at 100% load and the decoder at 33% load, all while the CPU is at only
5% load.
Sven
On 31/08/16 22:58, SDSS wrote:
> After some googling I was able to find out how to use ffmpeg to convert MKV
> videos in H.264 format to MKV videos in H.265 format. I looked into this
> because I have a lot of H.264 videos, which I would like to reduce in size,
> as H.265 can reportedly do.
>
> However, in my search I also found out that, according to many, re-encoding
> H.264 videos as H.265 is a waste of time, for the most part, on the grounds
> that H.264 videos are already compressed, and re-encoding them as H.265
> won't achieve much.
>
> I have run a few tests, changing the CRF and presets parameters, and I can
> re-encode my H.264 videos as H.265, in such a way that the quality of the
> resulting H.265 material seems to be pretty much the same as that of the
> original H.264 - but its size is not all that much smaller. This seems to
> corroborate those opinions above.
>
> Would it make sense to uncompress the H.264 first, and then encode the
> resulting video material with H.265? Is this even possible, in general, with
> ffmpeg, in particular? More to the point, is the H.264 to H.265 conversion a
> rather pointless exercise? It is clear that H.265 will shine when applied to
> original, uncompressed sources - but maybe it is indeed pointless to do an
> H.264 to H.265 re-encoding.
>
> Views from the experts on this would be much appreciated.
>
>
>
> --
> View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Reencoding-from-H-264-to-H-265-tp4677317.html
> Sent from the FFmpeg-users mailing list archive at Nabble.com.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list