If property stolen or embezzled comes into the custody of the magistrate, it shall be delivered, without prejudice to the state, to the owner upon his application to the court and on satisfactory proof of his title, after reasonable notice and opportunity to be heard has been given to the person from whom custody of the property was taken and any other person as required by the magistrate, and on his paying the necessary expenses incurred in its preservation, to be certified by the magistrate.