Help with settings for AVI to h.265

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
jeffshead
Posts: 2
Joined: Sun Feb 03, 2019 9:08 pm

Help with settings for AVI to h.265

Post by jeffshead »

I recently replaced an Android TV box with a NVIDIA Shield TV. Kodi 17.6 has issues on the Shield 7.2.2 so I installed Kodi 18. That fixed the original issues but now none of my AVI's will play unless I change the Kodi settings to eliminate HW acceleration. That of course causes issues with other file types.

I have used a few different "AVI fixer" apps which found no issues with my AVI files and I have even changed the container to MKV. That did not help. The files are old and someone suggested that GMC2 / QPel may be the problem. I have come to the conclusion that the only option is to re-encode them. I believe the older versions of Kodi automatically turned off HW acceleration for files smaller than 800 pixels wide but Kodi 18 does not do this. I went out and bought a GeForce GTX 1060 card and used ffmpeg but the resulting files are almost twice as large as the originals and I see a degrade in quality. Below is the ffmpeg command line I used:

Code: Select all

for /R %%I in (*.avi) do ffmpeg -i "%%I" -c:v hevc_nvenc -preset slow -cq 18 -g 150 -c:a aac -b:a 160k "%%~nI.mkv" & echo del "%%I"
I tried using Handbrake but I get virtually the same results with the presets and some settings don't use the NVIDA GPU so it takes forever.

There must be a happy compromise. Can someone please suggest some other commands or Handbrake settings for me to try? There must be a way to see little to no quality loss converting to h.265 without increasing the file size, isn't there?

Below is a link to one of the hundreds of files I want to convert:

AVI file (135 MB):
https://filebin.net/b83fiziyyz9jc6l9

MediaInfo:

Code: Select all

General
Complete name                            : C:\1.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 136 MiB
Duration                                 : 22 min 26 s
Overall bit rate                         : 845 kb/s
Writing application                      : VirtualDubMod 1.5.1.1a (build 1639/release)
Writing library                          : VirtualDubMod build 1639/release

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L3
Format settings                          : GMC2 / QPel
Format settings, BVOP                    : No
Format settings, QPel                    : Yes
Format settings, GMC                     : 2 warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 22 min 26 s
Bit rate                                 : 643 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.087
Stream size                              : 103 MiB (76%)
Writing library                          : XviD 0.0.09 (UTC 2003-03-25)

Audio
ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Format settings                          : Joint stereo / MS Stereo
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 22 min 26 s
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Stream size                              : 30.8 MiB (23%)
Alignment                                : Split accross interleaves
Interleave, duration                     : 42  ms (1.00 video frame)
Interleave, preload duration             : 464  ms


I have many files so I thought using hevc_nvenc would be the best option.

HandBrake version (e.g., 1.0.0):
1.2.0 portable

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows Server 2012 R2
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Help with settings for AVI to h.265

Post by mduell »

The hardware encoders like NVENC trade off quality/size for speed, just speed. They're intended for realtime encoding (like streaming) with throwaway results. If you care at all about size efficiency, they're not for you. You may be able to use NVENC for realtime transcoding in Plex, and just stream the result over the wire and not care about the size, which could deliver decent quality if you get the bitrate high enough.

For low res content (really anything below 4K that has previously been aggressively compressed) you're not going to see improvement with H.265 even with a software encoder.

I'd try testing a few different x265 (not NVENC) encodes at the slowest preset you can tolerate and different quality settings (move the RF by a couple points for each) to see if you can find a balance of size and quality that you're personally satisfied with.
jeffshead
Posts: 2
Joined: Sun Feb 03, 2019 9:08 pm

Re: Help with settings for AVI to h.265

Post by jeffshead »

Thanks for the info. I have hundreds of files to convert. That's why I want to use NVENC. It would take many, many days otherwise.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Help with settings for AVI to h.265

Post by mduell »

Then you're going to end up with much larger files to preserve quality.

Or do the transcode on the fly.
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: Help with settings for AVI to h.265

Post by Woodstock »

One thing about using handbrake's queue, or a batch job running the Command Line Interface, is that YOUR time is done up front. "Hundreds of files to convert" can be done while you're not there.
Deleted User 13735

Re: Help with settings for AVI to h.265

Post by Deleted User 13735 »

These are extremely low quality h263.
Normal preset x264-cpu will be plenty fast.
nhyone
Bright Spark User
Posts: 252
Joined: Fri Jul 24, 2015 4:13 am

Re: Help with settings for AVI to h.265

Post by nhyone »

As @musicvid said, you can just use x264.

If you want to transcode a low-quality source, the first thing you want is to discover the "equivalent" CRF -- the CRF that will give you the "same" quality as the source.

I tried x264, veryfast preset, CRF 22 (80.2 MB), 24 (66.8 MB), 26 (56.7 MB), 28 (49.0 MB). It seems to be 24 - 26. (x264 veryfast is pretty fast.)

I then tried veryfast preset, tune animation, CRF 24 (73.0 MB), 26 (62.0 MB). The file size increased a little, but CRF 26 looks really close. It is not quite the same because the source has tons of mosquito noise. They are not preserved exactly with such high CRF. (I doubt anyone cares.)

If you can spare the time, use NLMeans denoise. It makes it better than the source. I tried just one encode as it is very slow (CRF 24, veryfast preset, tune animation; NLMeans denoise, medium preset, tune animation). Size is 67.5 MB. Much, but not all, of the mosquito noise is gone.

To really improve the video, you need to use dedicated filters that undo mosquito noise and edge enhancement. However, that's beyond HandBrake.

Note: the size above includes audio. The original is MP3 at 192 kbps, which is way overkill for this cartoon. I used AAC at 96 kbps, which is also an overkill. However, I did not have the FDK-AAC encoder as I used the pre-built Windows app. Otherwise, I would have used 64 kbps HE-AAC.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Help with settings for AVI to h.265

Post by mduell »

If you're at all concerned about quality for size you probably don't want veryfast.
nhyone
Bright Spark User
Posts: 252
Joined: Fri Jul 24, 2015 4:13 am

Re: Help with settings for AVI to h.265

Post by nhyone »

Original (135 MB)
avi_0008.png
avi_0008.png (373.39 KiB) Viewed 596 times

x264, CRF 26, veryfast preset, tune animation (62.0 MB)
1_veryfast_crf26_tune_animation_0008.png
1_veryfast_crf26_tune_animation_0008.png (326.13 KiB) Viewed 596 times

x264, CRF 24, veryfast preset, tune animation; nlmeans medium, tune animation (67.5 MB)
1_veryfast_crf24_tune_animation_nlm_med_animation_0008.png
1_veryfast_crf24_tune_animation_nlm_med_animation_0008.png (302.3 KiB) Viewed 596 times
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Help with settings for AVI to h.265

Post by mduell »

Stills don't tell you much of anything about how video looks.

Mixing veryfast and nlmeans is a... very strange choice.
Post Reply