Optimal ffmpeg-transcode settings, including color-space, color-range etc.?

0

First, let me explain the situation: I have a whole boatload of various kinds of videos that I wish to trancode to HEVC in order to save storage-space. I do realize that there's some amount of loss in quality when transcoding, but it is what it is. I do use NVIDIA's NVENC because otherwise it'd take literal years to finish the job and I use constant-quantizer-mode on it as I'm not targeting a specific filesize and am instead targeting constant quality as long as it produces a small file than the original -- using VBR, for example, would still be targeting a specific filesize, even if the target is looser than with e.g. CBR, so that's not quite what I am after. I also wish to retain as much as possible of the original file intact, only touching the video (which is why I use -map 0 -c copy)

With that said, I am basically doing the following.

  1. Grab colour-space etc.: colors=$(ffprobe -v error -show_streams -select_streams V:0 "$i" |grep color|grep -v unknown|xargs|sed 's/color_/ -color_/g'|sed 's/=/:v /g'|sed 's/color_space/colorspace/g'|sed 's/color_transfer/color_trc/g')
  2. Transcode: ffmpeg -v error -y -threads 2 -hwaccel cuvid -c:v h264_cuvid -i "$i" -map 0 -c copy -c:V hevc_nvenc -preset:v slow -rc:v constqp -qp:v 25 -profile:v main -tier:v high -spatial_aq:v 1 -aq-strength:v 1 -rc-lookahead:v 32 -weighted_pred:v 0 $colors $outputfilename

A note on spatial_aq: using VMAF, I've noticed that enabling it does improve quality somewhat, but cranking aq-strength up increases output's filesize disproportionally. I can get a similar filesize with leaving aq-strength at 1 and instead lower cqp, but this way produces far better quality than high aq-strength. Actually, cranking aq-strength to the max may end up producing a bigger file than the original!

Now, the problem is that even after googling for a while, I have very little understanding of the various color-space-stuff and I don't really know if I am doing this thing right. If the input-file is limited-range, would the encoder be able to do a better job if it was expanded to full-range and, if so, would I be able to use scale_npp for that? Is there anything else I should be aware of? I also don't quite know what I should do in case ffprobe returns unknown for the various color-range etc. fields, if anything. Would it be beneficial to set some defaults, then, or should I do as I do now and omit all those in such case?

Any input would be appreciated.

WereCatf

Posted 2019-08-21T10:35:53.057

Reputation: 1

No answers