Getting firmware version from .BIN file

I am using a custom script to generate a csv file with all the data in the BIN file. The script is based on the functions defined in pymavlink/
Everything works fine however it would be useful for me to be able to automatically extract from the BIN file the version of Ardupilot for compatibility purposes.
Is this info stored somewhere and if yes how can I access it?