2

I'm currently recording gameplay footage through OBS in a near-lossless format, which preserves quality nicely, but generates gigabytes of video. For distribution, I want to re-encode my video files as H.265 with FFmpeg.

My current FFmpeg settings look as follows:

ffmpeg -i infile.mkv -c:v libx265 -crf 16 -preset slow -c:a aac outfile.mp4 

However, when encoding video files, there is a bit of a balance between quality, file size and encoding time. A faster preset will make encoding time faster, but increase file size. And a higher CRF value will result in smaller files, but with lower quality.

So far, I've tried using the hevc_nvenc encoder with preset "p7", which should be "slowest (best quality)". While that codec was undoubtedly faster, it also produced unacceptably low quality. Perhaps I didn't understand how to use those codec options, but I couldn't find a good documentation either.

To summarize, is there a way to decrease encoding time, possibly by utilizing my nVidia RTX 4070 Ti, without (noticeable) sacrifices in quality or file size?

Giacomo1968
59.1k23 gold badges180 silver badges225 bronze badges
asked Mar 14 at 20:17
3
  • Show the command tyou tried with HEVC. Commented Mar 14 at 20:28
  • I've tried ffmpeg -i infile -c:v hevc_nvenc -cq 20 -preset p7 -c:a aac outfile and now the file looks good. I suppose I made a mistake when first encoding via hevc_nvenc. Commented Mar 15 at 22:53
  • 1
    You can always answer your own question (and accept that answer) to show others how you solved the problem. Commented Mar 17 at 12:57

1 Answer 1

2

I've looked a little deeper into this, and it seems that my original test using hevc_nvenc was flawed, which lead to noticably lower quality.

However, after some experimentation, the following flags were usable for me:

ffmpeg -i infile -c:v hevc_nvenc -cq 1 -c:a aac outfile

In my initial tests, the -cq flag was missing, which lead to it being set to "auto", which in turn lead to quite poor visual quality.

In my tests, a 166 MB large video file was transcoded into a 52 MB large file, with no visible loss in quality.

I also did more tests with preset levels, specifically testing -preset p4 (the default) and -preset p7. In both scenarios, file sizes remained identical. Speed was 5x and 1.85x, so the slowest preset was significantly slower. Visual quality seemed to be unaffected by using the default preset, but my sample size was too small to really judge.

I'm sure there are more flags that might potentially affect quality, encoding time or quality (profiles, levels, etc.) but I know too little about video encoding to really play with those.

answered Mar 18 at 11:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.