The firmware you supplied is for a device class 68 - it's neither K41 nor K51 - and I forgot to ask what the firmware was for, and you didn't say.
That means that hiktools is not quite extracting the cramfs.img correctly from the firmware wrapper - the new_20.bin file is being left on the end of cramfs.img
So hiktools cannot do the whole job of unpacking and repacking that specific firmware.
In order to do that, some manual work cutting and splicing would be needed.
Tedious - but certainly possible with care.
That is the reason i exracted header, cramfs and new_20.bin with a hex editor. In the new_20.bin there is a timestamp (2017 Jan 03 20:44:22). Just fo fun i added one second and the update fails. Could it be that i have to change the Version number which is stored in the update? Maybe the DVR saves the MD5 of the last update and checks that i want to update the same version but with a different MD5?
I combined the header from an older firmware with the new one just to look what will happen. The error "Firmware mismatch" doesn't show up. The DVR reads the firmware file till the end and then shows the error "Upgrading failed, execute program error"
So there must be another cheksum stored somewhere in the header or in the new_20.bin
@alastairstevenson: can i upload the header, cramfs and new_20.bin so that you could check that i am doing it right?
To make changes and to upgrade, I had to use the serial console to erase the existing system and app partitions and manually apply updated tweaked firmware.
Not for the faint-hearted or non-techy types.