How to enable HW accelerated proxy encoding in Kdenlive

Since this was a bit tricky, I think it will be useful to write it somewhere.

So Kdenlive can generate proxy clips, that are smaller and lighter representation of currently processed video files. With proxy you can see more (or more complex) video effects in real time. My computer was able to handle 1080p files directly (not in real time – but close enough to be editable), but since I switched to 4k … I was also force to use proxy :).

Anyway, proxy usage is straight forward. You can define it on project level, and mark if you want to have auto generated proxies for files with width larger then X pixels (yes, this is width – it’s not stated anywhere). Or you can right click mouse on clip, in video list, and check mark “proxy” (this also works for entire folder).

So, by default in Kdenlive 18.12 all proxy clips are software generated. I’ve seen already in Refactory version, there are some HW config setups. I did some testing, and even my outdated Haswell (i5-4690) architecture is capable of mpeg2 and h264 hardware accelerated encoding on decent level.

And just to clarify, I’m not using hardware encoding of my final movies because I use mostly h265/hevc 10bit codec and this is nowhere near my server CPU feature set (I don’t have additional GPU card – just build-in in Intel processor) and soon (I guess) we all switch to VP1 anyway.

So the tests… default mpeg2/ac3 software proxy encoding makes about 50fps, eating up all 4 cores. Hardware decoding+encoding h264 makes 160fps – and CPU is totally free 馃檪 so there is something to fight for.

EncodingDecodingCodecFPS
softwaresoftwareMPEG56
softwaresoftwareH26422
hardwaresoftwareMPEG237
hardwarehardwareMPEG2167
hardwaresoftwareH26434
hardwarehardwareH264176

Above you can see short comparison of different decoding and encoding scenarios for 4k h264, 45 seconds long video. Output format is 1280 pixel width proxy clip. I’m also using HW scaling if there is hardware accelerated encoding.

Like you can see, it’s really important to have both decoding and encoding done by HW. And keep in mind, that not only we get faster proxy encoding, we also have free CPU for normal work with Kdenlive during proxy generating process.

Ok, so what is the “magic” setup? This is normal ffmpeg command line for HW accelerated encoding/decoding – so you can easily modify it to your needs (ex. different hardware). A bit tricky was to find how to put encoded file name not on the beginning of the argument line (as by default). But after a quick look in to the Kdenlive code, necessary stuff was already there – but I was determined even to write it by myself if it wasn’t there 馃槈 Kdenlive will put source file name after the “-i” switch.

-vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i -vf hwupload,scale_vaapi=w=1280:h=-2:format=nv12 -b:v 10M -ab 128k -c:v h264_vaapi -c:a ac3

And that’s it. Just be aware – this will work only with HW decoder. So all your clips have to be decodable by your HW. This is no problem for me, since almost all my material is h264, but if you will have something more exotic, what is not HW decoded – this will not work – there is no fall back to software decoder.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x