Scripting to Automatically Convert & Replace Videos to x265 / HEVC
#1
Hey Guys - 

Want opinions and thoughts on an idea, please...

So I have an extensive media library at home which takes a ton of space.  I keep my media on a 43tb disk pool made up of 10 drives and am almost out of space (in pool and case, too) Smile  I digitized many of my titles from blu-ray long ago and most are x264 with a variety of settings to where each title averages 4gb - 20gb.  What I'd like to do is convert each of these to HEVC / x265 to gain much of my space back while retaining quality.  I know even with a good CPU, doing just one takes a long time even with a good CPU; so had an idea. 

I'd like to set up / write scripting for a spare computer which is dedicated to doing the following:
  1. Recursively scan a network share for a video which meets certain criteria (like is x264, a minimum size, length,etc)
  2. Once the first one if found, copy it locally then convert it to HEVC / x265 with pre-defined profile(s)
  3. Once finished, move the transcoded video back to it's network source folder replacing the original then send notification
  4. Repeat - If done correctly, the next scan should skip the same video and move to the next
The PC wouldn't be the fastest, but it really wouldn't matter as it would be a spare one dedicated to doing this in a headless fashion.  It would be great to have a web interface to check status, but I don't have that much time to devote Smile

My Questions
  1. Is anyone aware of existing scripts / apps which do this or at least parts of it already?
  2. If not, what would you suggest be the platform for building this?  I'm more of a PowerShell guy, but would think a Linux distro might be best for stability plus would require less overhead resources 
  3. For the conversion part, would Handbrake CLI be my best choice?
Any thoughts or suggestions you have would be very much appreciated - Thanks!
- BzowK -
Reply
#2
I have done conversions from h264 into h265/hevc via 'simple' bash batch scripts per single folder, on an Ubuntu 16.04 machine using ffmpeg combined with a Nvidia GTX950. Converting videos using software conversion (e.g. Handbrake) is said to give 'better' results, but it all depends on your own expectations and view on quality. Results can vary quite a lot as it all depends on how good the source material is.

In simple terms: garbage in, garbage out. For example grainy videos are hard to compress further, where as cartoons are very well converted. In general my overall results went from 55% to sometimes 92% reduction in file size, but that also depends on how good you want your end result to be.

Also, having your average PC do the converting or using a GPU with hardware accelerated encoding makes a lot of difference in time AND electric power consumption. You can be surprized on how much electricity a PC can slurp from the socket. Say a 720p h264 video will be handled by the CPU with 7-10 fps (my experience with an old Core i3 3225 Ivy bridge), a GPU (Nvidia GTX950) can do that with 100-150 fps. By the way, a 1080p h264 video was done 2-3fps on the CPU in my computer *cough*... But newer CPUs will likely yield a better result, although nothing like when a GPU does the encoding.

A single 90-minute video that runs at (roughly) 24fps has 90*60*24=129.600 video frames, so in a worst case scenario:
- At a 7 fps conversion to HEVC using the CPU, it will take 129.600/7=18.514 secs => 308.5 minutes => over 5 hours...
- At a 100 fps conversion to HEVC using the GPU, it will take 129.600/100=1.296 secs => 21.6 minutes.
5 hours vs 21 minutes makes a whole lot of difference on your home's electric power meter.
However, it all comes down to the specific settings for the HEVC conversion. Your mileage will vary.

BTW, on average I saved some 75% disk space in "hevc'ing" my video collection. Not all of them are perfect copies, but that's what you get when doing batch processing several videos at a time. Each video can have its own characteristics and thus requiring different conversion settings.

I would recommend to first start testing with single videos and see what the results are. It will give you some idea how long converting your entire collection will take (a couple of months at least) and what the quality will be like.
Reply
#3
Klojum,

This sounds exactly like what I want to do. I'm not good with scripts etc. Can you tell us what script/syntax you use. I would be using a Mac for all this converting.


Thanks,

Dan
Reply
#4
Klojum - 

Apologies for the late reply, but thanks for the detailed answer!  I, too; would like to see some examples of scripts you used.  When trying out Handbrake, it took forever (as you mentioned).  I didn't think of leveraging my GPU (970 GTX).  

I use my workstation for a ton of things including work so bogging down it's resources wouldn't be great.  Therefore, the ideal solution I'm aiming for would be to use one of my spare systems as a dedicated converter.  It wouldn't have as good of a CPU / GPU (think the next best one I have is a 680 GTX) but if I could automate it wouldn't matter.  I considered a docker container configured to do it, but the resources there would be much less.  If I could just get it to where I could drop files to convert into a folder / share and have them automatically converted then send a pushover notification after each (dead simple to script), I think that would be a good start.

I'd be interested in seeming some of your scripts so if you could post a couple of samples, I'd appreciate it.  Thanks!
- BzowK -
Reply

Logout Mark Read Team Forum Stats Members Help
Scripting to Automatically Convert & Replace Videos to x265 / HEVC0