Jump to content

What is the best re-encoding H.264 to HEVC/H.265.


Oracle

Recommended Posts

Oracle

If you're like me, you have terabytes upon terabytes of files living on a NAS, and fight a consistent battle of managing storage capacity. I am currently in the process of re-encoding a bunch of .mp4's encoded as H.264 to .H265/HEVC .mkv's. Right now, my process is using a tool I created with FFMPEG, that allows me to do each file individually (This takes far too long).

So, I had some questions for other people facing this issue:

What is the best parameters to run for HEVC encoding in FFMPEG, and is there a way to convert all .mp4's in a sub-folder?

 

Link to comment
Share on other sites

roaku

I think the best parameters to generate H265 from a full quality source and the best parameters to minimize the damage from converting a lossy H264 to lossy H265 are probably two different things.

  • Like 1
Link to comment
Share on other sites

e123enitan

https://github.com/HaveAGitGat/Tdarr

Check this out works perfectly on windows, it will scan folder with h264 then encode to HEVC simple to use once U get the hang of it.

i have saved over 500gb space still encoding.

Ensure you have a good GPU such as Nvidia Quadro  P2000, this can perform heavy lifting transcoding or similar type.

I am not an expert just sharing my little sense of knowledge.

 

Edited by e123enitan
Link to comment
Share on other sites

Eigeplackter

Question is how did that affect quality of the files ? 🤔

I know Tdarr and I think it's pretty good idea, problem is it tries to imitate a "one-size-fits-all" solution.

This approach works well for caps, but not for different movie files. 🙁

Yes you can use it for easy bulk jobs like remove unwanted subs/audio tracks, but I wouldn't hand over transcoding.

 

i.e.

I have lots of old german tv movies (Edgar Wallace), those are all in H264, but the file size roams from 700MB to 9GB.

As for resolution that goes as low as 480p and up to 1080p (not remuxed).

So I went for transcoding all H264 files, larger than 5GB, to H265. I took me like 2 days and several runs,

till I had like 7 movies transcoded in an acceptable quality.

Now those are all around 60 yrs old movies and loosing a bit of quality on a grainy black-and-white movie isn't

going to be recognizable, can always tell it's the age 😂

 

But having FullHD or even UHD movies you don't want to loose a lot of quality, because that's the main reason

for having em in a high resolution. As every movies comes with another mb/s.

The Batman I ended up with UHD HDR10 [25,7Mb/s], for Captain Marvel UHD HDR10 Remux [47Mb/s].

You see if you hand over transocoding to Tdarr at a glimpse it will just use ffmpeg with a standard rate size

in the background and if you are not going to check every movie after transcoding, additionally decide to let

Tdarr delete the source file after susccesful transcoding, you might be in for a pretty bumpy ride with an 

unsatisfying end.

 

Link to comment
Share on other sites

RanmaCanada

There is no one size fits all profile.  Anything that was originally shot on film should never be re-encoded as the grain will just increase the file size to larger than the original.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
Ronstang
On 4/6/2023 at 2:56 PM, RanmaCanada said:

Anything that was originally shot on film should never be re-encoded as the grain will just increase the file size to larger than the original.

I have do disagree with that statement.  Most of my films are old and were shot on film and after encoding they are all smaller, sometimes way smaller, than the original file and the amount of compression is definitely proportional to the quality of the source.  Higher quality source....more compression.  But I do agree that graininess does cause file sizes of encoded content to increase.  One example is a film out my Hammer Collection that is about 20Gb off the blu-ray and 6Gb compressed while all other films are 2~2.5Gb with copied audio and the film in question is the grainiest I have ever seen right off the disc.....but it still compressed.

Link to comment
Share on other sites

tedfroop
On 05/04/2023 at 11:36, roaku said:

I think the best parameters to generate H265 from a full quality source and the best parameters to minimize the damage from converting a lossy H264 to lossy H265 are probably two different things.

Best way - find other experiences, collect data on how and what settings work.  Do a bunch of test files and be sure you are ok with the quality before converting en-mass. 

Most of all - remember that not all media reacts well to compression and you may need more than one strategy for films, cartoons, tv, SD quality, 720i or p quality, or HD, as each reacts differently to the process.

One of the other things not mentioned is that how you store audio affects this process as well.  Part of my strategy was to remove what I didn't need so most of my media has a single audio track (highest quality) and with very few exceptions, no subtitles.   Sometimes keeping the video format and removing a bunch of audio tracks you don't use can free up a lot of space too.

Link to comment
Share on other sites

Ronstang
2 hours ago, tedfroop said:

Sometimes keeping the video format and removing a bunch of audio tracks you don't use can free up a lot of space too.

You need to assess how you use your media.  If you don't have and never will have a surround system then you need to experiment with encoding options and downmix it to stereo and get rid of the surround track.  Or you can re-encode the surround to a lower bit rate and save space and most people will not notice the difference.  This is all subjective and you would need to do some testing before deciding on a routine.  

I don't know how to use it but once you decide you could use the Sickbeard script to do this to all your files unattended.  At some point I will have to learn as I have about 8K recorded movies from TV that I will probably do this to.

Link to comment
Share on other sites

RanmaCanada
On 28/04/2023 at 12:05, Ronstang said:

I have do disagree with that statement.  Most of my films are old and were shot on film and after encoding they are all smaller, sometimes way smaller, than the original file and the amount of compression is definitely proportional to the quality of the source.  Higher quality source....more compression.  But I do agree that graininess does cause file sizes of encoded content to increase.  One example is a film out my Hammer Collection that is about 20Gb off the blu-ray and 6Gb compressed while all other films are 2~2.5Gb with copied audio and the film in question is the grainiest I have ever seen right off the disc.....but it still compressed.

My example is that the original Alien movie has so much grain that encoding it to HEVC, and being able to preserve the details, makes the encode far larger than the original.  AV1 is supposed to handle grain encoding, but the community is so fragmented, and the encoding switches are so stupid and nonsensical while being hidden behind gatekeepers, it will never come to fruition, nevermind the sheer magnitude of computing power required to get anything above 0.1fps if you want quality (not using that garbage SVT encoder).

HEVC still can't handle grain to the extend that AVC can, and we'll probably have to wait for VVC or AV2 for something that can be comparable.

Link to comment
Share on other sites

Ronstang
1 hour ago, RanmaCanada said:

My example is that the original Alien movie has so much grain that encoding it to HEVC

I'll find that out soon enough as I recently ripped the entire Alien collection in Blu-Ray onto a hard drive to be encoded when I get around to it.

Link to comment
Share on other sites

RanmaCanada
On 01/05/2023 at 20:10, Ronstang said:

I'll find that out soon enough as I recently ripped the entire Alien collection in Blu-Ray onto a hard drive to be encoded when I get around to it.

We already tried it on Doom9.  It did not go well.  If you want acceptable loss, then yes it can be done, but if you want a transparent encode, then no.  I do my movie encodes to CRF 16-18 pending on the age and whether it's a film or solid state recording.  I do refuse to re-encode anything to HEVC from the 80's and lower, especially anime haha.

Link to comment
Share on other sites

tedfroop
On 02/05/2023 at 21:10, RanmaCanada said:

We already tried it on Doom9.  It did not go well.  If you want acceptable loss, then yes it can be done, but if you want a transparent encode, then no.  I do my movie encodes to CRF 16-18 pending on the age and whether it's a film or solid state recording.  I do refuse to re-encode anything to HEVC from the 80's and lower, especially anime haha.

It all has to do with the original digital conversion and whether it was done well plus whether it was done from original (or close to original) source material.  I have some older stuff that is impeccable quality from the 1940's and up. Most of the undesirable noise comes from poor quality digitization and generational copies of source material.  

As an example, for people of my generation, Looney Tunes cartoons were copied over and over and over for TV use from the '50s through the '80s and were horrible washed out grainy and awful.   However - my Golden Collection DVD stuff is crisp and colorful, because they came from restored first generation copies of original material

  • Like 1
Link to comment
Share on other sites

Ronstang
2 hours ago, tedfroop said:

It all has to do with the original digital conversion and whether it was done well plus whether it was done from original (or close to original) source material.  I have some older stuff that is impeccable quality from the 1940's and up. Most of the undesirable noise comes from poor quality digitization and generational copies of source material.  

As an example, for people of my generation, Looney Tunes cartoons were copied over and over and over for TV use from the '50s through the '80s and were horrible washed out grainy and awful.   However - my Golden Collection DVD stuff is crisp and colorful, because they came from restored first generation copies of original material

Ding! Ding! Ding!

  • Thanks 1
Link to comment
Share on other sites

Oracle

I've been going through this process of re-encoding 1080p/720p H.264 into H.265 as a space saver. I'm curious as to what parameters you are all using with FFMPEG to get the best quality but also the smallest file size.

Link to comment
Share on other sites

Ronstang
51 minutes ago, Oracle said:

I've been going through this process of re-encoding 1080p/720p H.264 into H.265 as a space saver. I'm curious as to what parameters you are all using with FFMPEG to get the best quality but also the smallest file size.

I have sent you a PM because I needed to explain a few things about the settings I use.  You can try them as a starting point for testing.

Link to comment
Share on other sites

rbjtech
On 01/05/2023 at 23:47, RanmaCanada said:

My example is that the original Alien movie has so much grain that encoding it to HEVC, and being able to preserve the details, makes the encode far larger than the original.  AV1 is supposed to handle grain encoding, but the community is so fragmented, and the encoding switches are so stupid and nonsensical while being hidden behind gatekeepers, it will never come to fruition, nevermind the sheer magnitude of computing power required to get anything above 0.1fps if you want quality (not using that garbage SVT encoder).

HEVC still can't handle grain to the extend that AVC can, and we'll probably have to wait for VVC or AV2 for something that can be comparable.

Some movies you just want the maximum quality possible because the film is ALL about the quality of the Cinematography - Alien is one of those films.   It has a large number of essentially 'static' but dark scenes - and thus your eyes WILL pick up on every little detail as they have time to - thus you need every little detail to be there.

So for the sake of saving lets say 25GB of space (I think Alien is about 50Gb 4K Remux) , you have effectively destroyed the movie... 😪

Now take a fast paced action movie with constantly moving scenes - would you really notice if it lost a little quality - probably not, so these compress reasonably well without any 'perceived' quality loss - it's there of course, you just don't notice it.

Link to comment
Share on other sites

tedfroop
23 hours ago, Ronstang said:

Ding! Ding! Ding!

Thanks to a severe anxiety disorder I am a little dingy already but thanks.....

Everyone is always looking for a "one size fits all" ripping setting but really?  There are other things that seriously affect quality like @rbjtechmentions.  Action, light levels, color, frame rates, and original size all affect size and compress-ability and finished quality.  

Which is why I have at least half a dozen ripping profiles.......

Link to comment
Share on other sites

roaku

Strange, I'm overkill with audio but with video, unless it's banding so bad it makes it look a gif from 1995, I don't mind. The Very High Quality (or whatever they're named) HEVC setting for Handbrake are good enough for me and anyone who might also be watching.

I also have yet to venture into 4k land and have a living room size screen. 🤷‍♂️

Link to comment
Share on other sites

rbjtech
11 hours ago, roaku said:

I also have yet to venture into 4k land and have a living room size screen. 🤷‍♂️

I would actually say it's the HDR/DV that has improved the 'picture' much more than the resolution.  Unless you have a very large screen and/or viewing distances are pretty close - I think Joe Average is really not going to notice the 'resolution' differences.

To me - only some 4K HDR/DV's are 'wow' (probably because of the colour's jumping from the screen) others are frankly a big disappointment and there is little to be gained over a well upscaled 1080p on a 4k display. 

I still get comments to this day on my old 1080p Panasonic Plasma TV - people ask if that is UHD as it looks so good - nothing to do with resolution, but it's 'colour' is deep making even lowish quality 1080p rips look the business.

So if you're happy with the quality you watch - then I would say don't get dragged into the 4K 'band wagon' as it opens up a whole new world of pain (especially the HDR/DV 'debacle' .. 🤬 ) for mixed gains.

Edited by rbjtech
  • Like 1
Link to comment
Share on other sites

roaku

@rbjtech

Ha, I've had my Panasonic Plasma for over a decade now and it's staying as the main screen until it tells me it's time to retire.

Those Panasonics really were a special combination of picture quality and price point.

  • Agree 3
Link to comment
Share on other sites

Ronstang
8 hours ago, rbjtech said:

So if you're happy with the quality you watch - then I would say don't get dragged into the 4K 'band wagon' as it opens up a whole new world of pain (especially the HDR/DV 'debacle' .. 🤬 ) for mixed gains.

This is my position.  I watch mostly old classic movies that were filmed 30-90 years ago.  I have noticed that even on Blu-Ray that a lot of these movies aren't really that high quality.  I'm not saying they are bad or unwatchable but they just aren't really what one would expect from a Blu-Ray since they were actually shot on real film.  Now these days some of these films are coming out on 4K but there is going to have to be a lot of digital enhancement to make them actually better.....but then the question becomes "is that actually better".  You kind of have to keep this stuff in perspective and not get sucked into the rabbit hole of constantly seeking that little extra here and there.  It's expensive and a waste of time in my opinion.  

Most of my content is recorded from TV, especially TCM, and even when I have a Blu-Ray copy side by side comparisons are hard to see any difference even though the Blu-Rays are usually at least 2X the size of as recorded.  Once encoded the file size is only different because of the size of the audio file and once again....hard to see any difference.

I understand the limitations of the content I watch and I am very pleased with the results I get and so are all my users. Yes, some movies are better than others but after exhaustive comparisons over the last couple years when I compare my encodes to the originals the issues I see are actually in the original so I no longer question anything and now I just enjoy my content instead wasting time trying to make limited gains if any.

Newer movies encode so well from a 1080P or 1080i source that it is almost impossible to tell they are not off of a disc.  Most users can't see the difference.  My wife is constantly amazed.  I'm happy with my content because I understand the limitations we face here and considering if I have seen them before it was probably years ago on a 4:3 CRT TV with pan and scan so this is an awesome upgrade to say the least.

  • Like 2
Link to comment
Share on other sites

tedfroop
14 hours ago, rbjtech said:

To me - only some 4K HDR/DV's are 'wow' (probably because of the colour's jumping from the screen) others are frankly a big disappointment and there is little to be gained over a well upscaled 1080p on a 4k display. 

Yes indeed.  There always seem to be companies trotting out the same digitization they used for the DVD in newer formats and not really changing the source material, just releasing it in a new format.

Having recently moved into the 4k realm for display I also agree that a quality image - pretty much at any resolution, is still a quality image at any other resolution.  When the new TV was within reach I did some upscaled test files because of concerns some older low res stuff may not look great......wrong.  It looks virtually the same at either resolution.

Broadcast TV?  Again, there is some gain in resolution, but nothing earthshaking.  Color again is the biggest difference.

All that disappoints me in all this is as an amateur photographer, I understand how color display is affected by surroundings, room lighting, color temperature of room lighting, and it would be nice if manufacturers would start adding color calibration to displays.

  • Like 1
Link to comment
Share on other sites

Ronstang
On 5/6/2023 at 5:03 PM, tedfroop said:

Broadcast TV?  Again, there is some gain in resolution, but nothing earthshaking.  Color again is the biggest difference.

The problem with TV is that depending upon channel it is so compressed that there is so much loss there is no upscaling that can correct it and you end up with macro-block pixelation.  Network TV is OK and some of the cable channels but there are still a lot of SD channels for some unknown reason and how they look really depends....it basically comes down to what material is available.  MeTV bounces all over the map from good to terrible on quality.  Back in the days of syndication many shows found their way to oddball stations at rather low rez and in some cases of old TV shows those are all that exist these days for what's left to source DVD releases.  Two cases.....Mannix survived in rather decent quality yet  Cannon of the same period did not and you can see this in what's available on DVD.

You have to be ESPECIALLY careful of companies putting these older shows out on Blu-Ray because many are simply the same available prints that are out on DVD with just more episodes on fewer discs.....this is not a Blu-Ray release and thus should not be priced any different than the DVD release yet many companies scam people out of their money this way.  There are exceptions....Batman (1966) on Blu-Ray are actually some pretty nice prints but others you will find if difficult to see any difference between the DVD and Blu-Ray release so buyer beware and do your research.  I had to explain this to several friends who bought into the hype.

BUT.....a high quality DVD encoded and they viewed thru emby on a modern TV will be hard to tell that it is not HD.  It all boils down to the quality of the source.

  • Like 1
Link to comment
Share on other sites

tedfroop
On 07/05/2023 at 18:51, Ronstang said:

Two cases.....Mannix survived in rather decent quality yet  Cannon of the same period did not and you can see this in what's available on DVD.

Yes, part of this again depends on whether they went back to archival originals or used generational copies to digitize from.

One of the other things in this is with "restored" material.  My Looney Tunes stuff is restored to "original" quality.  They didn't remove dust, imperfections, etc that were in the original print of the movie - because in the day - all they knew it to be was  a release that was shown in theatres for a few weeks or months. 

Otherwise,  experiments with AV1 continue.  My new TV does not play AV1 naively, but my Roku Ultra (4802CA).  Compression (from original source material) is excellent and there are a couple of places I have noticed artifacts but - one of the biggies is a "soft focus" effect on higher quality material.  A slight increase in ripping quality above the recommended level cures this and file size does not suffer.  I have yet to watch it through but LOTR Fellowship appears to be 4/5ths DTS-MA and 1/5th Video, so increasing size of the ripped file isn't a huge increase in finished file size.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...