By the time you read the first event from the log you don't know what binlog version the binlog has. To determine the version correctly it has to be checked if the first event is:
a FORMAT_DESCRIPTION_EVENT version = 4
-
if
event-size
== 13 + 56: version = 1if
event-size
== 19 + 56: version = 3otherwise: invalid