Many of the files I have for TV and Movies are arriving in HEVC (x265) format. As we all know, the RasPi doesn’t do too well with HEVC-encoded files.
So… I decided to write a python program that uses FFMpeg to transcode and replace them.
The program looks in your MyVideos107 database (either SQLite or MySQL) for files marked as HEVC, performs path subsitutions in case files are not stored on the same machine as Kodi, then converts them and copies them back to the original filename. It then deletes the HEVC entries in the database so that Kodi will redetect the metadata.
If there’s interest, I can post a Dropbox link. RIght now, the code is kinda klugy, but its functional. It works in my environment.
If someone wants to run with it and make it better, that’s cool too.
Let me know if y’all want a peek
UPDATE: Here’s the link to KodiTranscode V.1.0
Well, if the reverse transcoding is also possible, it would be nice and I would be interested.
I have too many h264, and I watch these on the TV only using a Vero 2 and soon 3
1 Like
That would not be hard to implement, really. Just a few changes to the code, and some additional logic to parse an additional configuration parameter.
Let me look into the ffmpeg command line changes to go to hevc instead of 264.
Cool. Thx
Thing is - the h265 can take up to 2/3 less space on disk, and it makes watching a good Full HD movie over WiFi possible.
The problem with repeatedly transcoding however is that you lose quality.
A simple way to think of it would be photocopying a photocopy.
1 Like
Agreed. I only plan to transcode once. And the small number of errors in a 1st gen copy is far, far better than the ridiculously chunky performance of HEVC on rPi (1 or 3).
A single transcode’s loss also beats having to locate and download thousands of files again, too.
I’m almost done with the code cleanup and documentation. Adding a few more bits and pieces and then need to add some error trapping so that people can get useful errors. Of course, since it’s Python, they can just go fix it
Vero 4K has an H265 hardware encoder and Vero 2 can encode H264 in hardware.
We’ve received some (albeit limited) interest in this. If there’s some demand we could make a small CLI wrapper to leverage this. It might be cool to say ‘Here’s Vero 4K which does 10-bit H265’, and here’s an H265 encoder.
Sam
Hey, if someone can make use of this code, great. I use Raspi since they are inexpensive. I have way more time than money, so the cost of the Vero is too much for me…
Since I’ve been snooping in the kodi database, and boy is it messy! There are lots of orphan records! It still works fine, but I may dig in there sometime and clean it up.
You should check out texturecache.py.
http://kodi.wiki/view/Texture_Cache_Maintenance_utility
Could be useful.
Just curious, how long does it take a Pi to convert an 50 minute 720p video from .265 to .264? If you download a whole season, will you be able to use the Pi that day?
I’m used to ffmpeg with nvenc acceleration
Lol, I don’t know. I wrote and executed this program on a Core2Quad q8200 running Ubuntu 16.04LTS.
I was getting about 25-35fps, so basically real-time.
A pi would be significantly slower. I recommend that you run this on a different machine (which is why I wrote all the path substitution code) so that you don’t totally kill your Pi.\
I updated my original post with a link to the tar.gz file.
Enjoy!
Let me know if you have issues and can’t fix them yourself. It’s pretty simple Python, but I’ve never been a great one for good code comments, etc… So if you’ve got questions about WTF was I thinking, please let me know,
This is quite different to the assumption that most would make by reading your first post.
It will run on a Pi. But why torture myself when I don’t have to?
Well, apparently, ffmpeg is not an available package for Raspian. I’m looking into what must be done to make this work on a pi.
I’ve temporarily killed the link until I can update the README file with more instructions.
Works great on Ubuntu. But I can appreciate the desire to do this ON the pi since it may be the only Linux box the end user has.
It should also work in Windows, although the colored ANSI output will look like ass on Windows, and the code is untested there.
libavcodec is in Debian. It should have ffmpeg like syntax.
Yeah. Found those, but some of the command line options (hide_banner) that I was using in ffmpeg aren’t available…
Apparently, you can compile ffmpeg, too. I’ll see if that works better.
There are also repositories which let you install ffmpeg on Debian without compiling.
Not sure if they’re available for Raspbian / armv6l however.
Found this:
http://blog.dragon-tortuga.net/?p=1601
Not sure I like adding a repository that gives me warnings because I don’t have their security key…
I’ll see if this works. It’s the only place I’ve found so far that seems to support compiling ffmpeg with HEVC on a pi.
I wonder why the Raspbian folks didn’t include this in repos…
Because Raspbian is based on Debian, which doesn’t include ffmpeg by default. They want to stay as close to Debian as possible
Needing to add a key when you add a new repository is standard. OSMC uses its own key: we just ship it with the image