lavf/matroskaenc: Check for valid metadata before creating tags