Log in

View Full Version : Converting H.264 to H.265


neutrogenik
20th November 2016, 15:23
Hey guys!

I'm using nvidia Geforce Experience (GFE) to record my screen when i play on my computer.

GFE uses my Nvidia GTX 680 graphic card built in H.264 hardware encoder to record the videos.

I would like to convert these videos to H.265 to reduce their filesize so it takes fewer time to upload them to youtube.

I would really appreciate if one of you could tell me which way should i better follow to do this as i'm a complete noob regarding H.265.

:thanks: a lot in advance for the help!

sneaker_ger
20th November 2016, 15:29
1. x265 is not a format, it's the name of one specific software encoder that encodes H.265/HEVC video.
2. x264 is not a format, it's the name of one specific software encoder that encodes H.264/AVC video. Your Nvidia GPU has its own H.264/AVC encoder, not x264.
3. Youtube doesn't support HEVC uploads anyways.

You could re-encode to a smaller file size H.264/AVC file using x264, tough. Many GUIs help with that, e.g. VidCoder, HandBrake, StaxRip, MeGUI, ...

neutrogenik
20th November 2016, 15:36
Danke for your answer sneaker :)

Yes my bad you're right, i meant H.264 to H.265 but you undertood what i meant! I edited my first post to correct this.

And you're also right about youtube, i'm very surprised about this but also found out that it works on vimeo so i'll just try to upload there instead :)

You could re-encode to a smaller file size H.264/AVC file using x264, tough. Many GUIs help with that, e.g. VidCoder, HandBrake, StaxRip, MeGUI, ...

Yes that's what i'm doing right now already but H.265 should help make it even smaller isn't it?

katzenjoghurt
20th November 2016, 15:40
YouTube will reencode your video anyway.
Apart from upload time it doesn't matter how small your source file is.
Better upload the video in the best quality you have.

neutrogenik
20th November 2016, 15:43
Upload time is what matters to me :)

I have a xDSL broadband with 100 kBps of upload speed so uploading raw videos from GFE takes way too long. So i'm hoping that re-encoding to H.265 would help me better quality / lower filesize / faster upload time :)

sneaker_ger
20th November 2016, 15:44
Yes that's what i'm doing right now already but H.265 should help make it even smaller isn't it?
x265 can offer the same quality at a lower file size than x264, yes. But this is mostly true for low bitrate (low file size) scenarios. At higher bitrates this advantage fades away or it may even become negative. So it depends on what bitrate you are aiming for (and the source type).

E.g. at 500 kbps 1080p x265 will most often be a lot better than x264. At 5000 kbps this may not be the case anymore.

neutrogenik
20th November 2016, 16:02
Original record from GFE is (H264) 1920x1200 59.94fps 40093kbps [V: h264 high L5.0, yuv420p, 1920x1200, 40093 kb/s]. You can download a 10 seconds sample here (https://ah1z.com:4443/owndoge/index.php/s/96I527qOv3bM7pf/download) (hosted on my private server). This took me 10 mins to upload.

Same sample re-encoded to lower bitrate is (H264) 1920x1200 59.94fps 14046kbps [V: Video Media Handler [eng] (h264 main L5.0, yuv420p, 1920x1200, 14046 kb/s)]. You can download it here (https://ah1z.com:4443/owndoge/index.php/s/gJn3nIyGLMcdQaz/download). This took me only 2 mins to upload.

This is over only 10 seconds timelapse. My videos are usually 20 mins long so the upload time is really faster when re-encoding and i would like to make it even better with H.265 if that's possible :)

neutrogenik
20th November 2016, 16:25
Well i found out how to do what i wanted thanks to this guide found on google:

http://www.techspot.com/article/1131-hevc-h256-enconding-playback/page4.html

Thanks to it i managed to reduce the filesize to only 4 mB and quality is almost the same, this is crazy :D

For the people interested in this topic, you can download the 10s sample re-encoded to H.265 here (https://ah1z.com:4443/owndoge/index.php/s/3XIjtCWU9od5p2E/download)

sneaker_ger
20th November 2016, 16:47
x264 at same size for comparison: https://www.sendspace.com/file/uivg2f

neutrogenik
20th November 2016, 17:15
Thanks sneaker!

I compared your video with mine and indeed yours has better quality indeed!

So this made me think that i could just change the bitrate on the hardware encoder on GFE, so i switched it from 50mbps to 10mbps and the quality is still quite good! I wish i could even lower it to 4kbps but it's good enough i guess :) I never thought the quality would be this good even at a low bitrate.

Thanks again for your help!

I took the liberty to upload your sample to my server so it stays online much longer.

I also made bmp screenshot of your sample and mine where you can see that your sample has better quality.

All files regarding this topic can be downloaded here (https://ah1z.com:4443/owndoge/index.php/s/EwNulxPtWdasAEy)

sneaker_ger
20th November 2016, 17:21
I compared your video with mine and indeed yours has better quality indeed!
I didn't say mine was better. :confused:
It was just to show that at same size x264 doesn't necessarily look bad. Next thing you could test is to upload both to Vimeo (or whatever service you end up using) and then compare their re-encodes.

neutrogenik
20th November 2016, 17:59
@sneaker > when i compare the 2 screenshot of your video and mine, i feel like yours has more details, that's why i said the quality is better, but that's only my opinion of course :)

It's easier for me to not re-encode the video and use GFE with 10k bitrate only so i wont bother try to upload the videos. Feel free to do it if you like.

@jq963152 > yes you're right! that's why i'll stick to the original encoder with lower bitrate that i used before :)

I'm now trying to find a way to change the bitrate of GFE to a custom value... But it's another story :D

#Edit: for anyone interested, i found out that setting GFE bitrate to 10 mbps actually enable a variable bitrate on the hardware encoding, from 4kbps to 8kbps so this is perfect! :)

JohnLai
21st November 2016, 06:46
Maybe you should consider using OBS?
There are more options for setting up nvenc or QSV (if you use intel cpu)

There are several nvenc presets that you might like in OBS. Example....High Quality Low Latency (2 Pass) preset?

dipje
22nd November 2016, 21:26
Using HEVC / x265 probably takes a lot of time, when you only want to make the file smaller so that you upload it quicker.

May I suggest using x264 with a very simple '--preset medium --crf 20' (or maybe '--crf 18' for more quality) to re-encode it to x264 but a smaller size?

GFE (and probably others) use a lot of filesize (bitrate) to make sure they capture something that is pretty close to 'perfect' quality. It isn't needed, and more importantly: x264 is so much better at 'getting more from the bits' that 50mbit/sec for NVEnc could mean 20mbit for x264.

Using the '--crf 20' option basically tells x264 to re-encode but 'to target a certain quality' and you'll see by the end how much smaller (or bigger, who knows) your file got. If you see too much quality loss (I doubt it, specially when you're going to upload it to youtube) you can go '--crf 18' to target a higher quality (the lower the number, the higher the quality but gives a bigger file. Going as low as 12 or even lower is basically overkill, not needed and may get your files bigger instead of smaller).

Specially if your clips contain sections where there isn't as much action on the screen (you standing still to explain something for instance, or you camping in a game :P) this method will reduce file size a lot, where dumb NVEnc captures will continue to use the same amount of filesize per second, x264 is smart enough to optimize parts with little to no motion.

x265 is too slow for what you want I guess.

You might also get a ffmpeg build (from here for example https://ffmpeg.zeranoe.com/builds/, choose the static latest version, 32-bit or 64-bit depending on your PC / wishes). This way you'll be sure it can handle audio as well and can handle any input format you throw at it (although there are x264 builds out there with more important formats as well).

ffmpeg -i "<input file>" -vcodec libx264 -preset medium -crf 20 -f matroska -y "<output file>.mkv"
ffmpeg -i "<input file>" -vcodec libx265 -preset medium -crf 24 -f matroska -y "<output file>.mkv"

You could also use '-f mov' to make a .mov file. I use .mov or .mkv because they support raw uncompressed pcm data. ffmpeg says .mp4 doesn't. Youtube takes both well.
Also note for x265 I used a higher crf value. The 'crf' values between x264 and x265 _are not the same_. If 'crf 20' gives you good quality-for-filesize, you must find the crf value for x265 for yourself. You can't just use the same value for both, they don't have the same meaning.

I use 'crf 24' here, which (for me) gave me about half the file size as the x264 version, and looks just a bit worse (should have crf 23, a bit too smoothed as x265 tends to do but otherwise still very good). It went at about 10 fps on my system, so my 1 minute test video took 6 minutes, gave me a 37 mb file.
With x264 at crf 20 it looks very fine, went at 25fps so it took just a bit under 2.5 minutes, gave me a 90mb file.
My source is from OBS-with-nvenc (not GFE but similar) and was 125 mb for that one minute (at 60 fps). I think GFE files are even a bit bigger than my current OBS setup.

neutrogenik
24th November 2016, 00:36
Hey guys and thanks for your messages :)

I find using Shadowplay with lowest bitrate possible quite easy because i have basicly nothing to do, the quality is good enough, file size is small and then i can upload without re-encoding, so i dont waste time about it.

Are you saying i could do the same with OBS and get better quality with same filesize?

dipje
24th November 2016, 12:09
mwah, 'not really'...

Shadowplay uses a constant filesize-per-second. So every second takes up the same amount of space.
You can set up OBS to vary that filesize-per-second. So easy parts take up less space, complex parts take up more space.

But since it all uses the same chip on your videocard I don't think you'll gain much. If you're happy with how it is now, stick with it. Shadowplay is easy enough, OBS can be give-or-take in setting it up :P
Just for my easy of mind I would try raising to something just above 10 mbps. 15 or 20 would be happier for me, but you decide what you're comfortable with.

The only real quality gain would be to use x264 instead of your videocard. That means that the compression is done completely on your CPU. This is where the quality-vs-filesize can be a real boost compared to NVEnc, but that means your processor is compressing _on the fly_ while gaming. It depends on your system, but for most gaming systems this can ruin the gaming experience (causing FPS drops, stutters or other performance issues). If you have a descent CPU and are playing easy games like League of Legends, it might be something to consider. But once again, if you're happy with NVEnc/Shadowplay at 10 mbps, stick with it.
I wouldn't go aim for too much 'perfection' when you're uploading it to Youtube or Vimeo anyway.

neutrogenik
25th November 2016, 13:22
Alright i'll stick with Shadowplay for the moment then :)

Thanks a lot for your message dipje :)

Btw for whoever reading this topic and might be interested, you can see the result of shadowplay recording at lowest bitrate settings and uploaded to youtube here: https://www.youtube.com/watch?v=wtpXNeAjv1g

I find the quality to be good enough: you don't think "this is bad quality" when you see it, even if you dont think "this is great quality" either. The middle ground is what i was looking for :)