Yes, context. In practice there is rarely a problem.
Written formal “you” is usually written with a capital S - Sie.
“Ihr” in this context is the plural familiar form of “you”, i.e. the plural of “du”.
(“du” used to be written with capital D in correspondence, but often isn’t now).
The word “ihr” has some other uses, but in those, it does not mean “you”, so I won’t complicate matters here.
One of the fun things in German is that pronouns change according to the way they are used, or in grammatical terms, according to the case, and also to the gender, of which there are three in German.
It’s a bit like the articles, der, die das, but slightly more irregular (just to add to the fun).
the best way to learn them would be the SSi way, which is essentially the way that Germans learned them, because no normal human being can carry around the declension table in their head and use it in real time to make conversation. If you try to, it obviously slows you down…
(as I know to my cost!)