Mystery in proof of Euclid Elements Book 7 Proposition 20 Below is a screen-shot of a video about the proof of Proposition 20 of Book VII of the elements. There is one step that I don't understand and seems to be completely glossed over by the proof. This is not a criticism of the video: many written sources around the internet give the same steps without the pictures, leaving me with the same problem. If anything the illustration in the video helped me pin-point exactly what my problem is.
The statement of the proposition is this:

Suppose $A$ and $B$ are positive integers and $CD$ and $EF$ are positive integers as well such that $A : B = CD : EF$ and moreover $(CD, EF)$ are the smallest pair $(x, y)$ such that $x : y = A : B$. Then $CD$ divides $A$ and $EF$ divides $B$.

The proof, as I understand it, goes as follows. We give a proof by contradiction, starting with numbers $A$, $B$, $CD$ and $EF$ such that $A : B = CD : EF$ and $CD < A$ but $CD$ does not divide $A$

*

*There exist natural numbers $p$ and $q$ such that $q$ divides $A$ and $CD = p (A/q)$, or, as the video puts it: $CD = (p/q)A$. Since $CD < A$ we have $p < q$. All this is off course completely uncontroversial.

*

*The assumption (that eventually must lead to a contradiction) that $CD$ does not divide $A$ translates in this language to $p > 1$.

*The video uses, as an example $q = 3$ and $p = 2$ but explains that these are arbitrary examples and other numbers would be good as well

*The quantity $(1/q)A$ is drawn in red in the picture



*The point $G$ on segment $CD$ is defined by $CG = (1/q)A$.

*

*By definition of $p$ we see that $G$ lies on $1/p$'th of $CD$ and since (by assumption) $p > 1$ we have that $G \neq D$ and $CG < CD$.



*Next step: now that we have the number $q$ we can talk/think/reason about the mystery quantity $(1/q)B$.

*

*This drawn green in the picture

*Since, by definition, the mystery quantity fits exactly $q$ times in $B$, some completely standard and easy and innocent reasoning about ratios tells us that it fits exactly $p$ times in $EF$.



*The point $H$ on segment on $EF$ is defined by $EH = (1/q)B$, so $EH$ is what I call the mystery quantity above.

*

*Since moreover $p > 1$ we have that $H$ is not equal to $F$ and the mystery quantity $EH$ is smaller than $EF$.



*Third step: by some completely standard and innocent reasoning that Euclid still manages to make sound complicated we conclude that $CG : EH = A : B$.


*Final step: since $CG < CD$ and $EH < EF$ we get a contradiction with the initial assumption that $(CD, EF)$ is the smallest pair of numbers in ration $A : B$.
Now my question:

What tells us that the mystery quantity $(1/q)B$ is an integer???

Nothing in the proof depends on $EH$ being an integer except for the final step. We can still find that $EH < EF$ and that $CG : EH = A : B$ only now the 'contradiction' becomes the claim that some fraction is smaller than the smallest integer with a certain property which is of course no contradiction at all.
However if the proof does indeed define the mystery quantity $EH$ as $(1/q)B$ then there is no reason to assume that it is an integer, unless some extra proof that $q|B$ is provided. I can't find such extra proof in the video but maybe I am misinterpreting something?

The full video can be found here
PS Of course I can come up with a proof that $q|B$ (or of the full proposition) using the Fundamental Theorem of Arithmetic, but this proposition is used by Euclid as part of the proof of that theorem. So 'Well, duh, everybody knows about unique factorization into primes so no need to elaborate on this' could not have been what went through Euclid's head when putting this proof in the way he did.
 A: It seems the best answer is given in the article posted in a comment:
Did Euclid Need the Euclidean Algorithm toProve Unique Factorization?
By David Pengelley and Fred Richman, American Mathematical Monthly 113, March 2006
For the benefit of future readers I promote the link from a comment into an answer and also I'll summarize the main point here, but I warmly recommend everybody to read it. There is a lot of interesting stuff in there!
Answer to the original question, based on the article:
On the one hand: yes I do miss something and so does the video. Namely: the definition of $A : B = C : D$ that Euclid uses is not the same as what we think.
I interpreted it as $A/B = C/D$. The video seems to interpret it as $A/C = D/B$. Both interpretations are of course equivalent.
However, according to the article, the expression $A : B = C : D$ means something stronger namely
There exist m, n, X, Y such that
$$A = mX, B = nX, C = mY, D = nY.$$
(Capitalization is mine but has actual meaning here (and to Euclid): we think of capital letters as length of line segments and of small letters as actual numbers counting the discrete number of times one segment fits into another. So small letters are actual natural numbers and capital letters are real numbers that can be thought of as natural numbers because we all take them from a set of real numbers that have a common 'unit' divisor)
Now with this definition the problem of my original question disappears.
On the other hand: while it is clear that $A : B = C : D$ implies $AD = BC$ the implication in the other direction is not clear at all (without using unique factorization) and we need both directions in the proof. (In my original part I filed this under 'completely standard and innocent manipulation of proportions' but with the new, stricter definition of $A : B = C : D$ it is neither standard nor innocent anymore.)
Euclid does realize it and makes a separate earlier proposition about this, proposition 19, stating that $A : B = C : D$ is equivalent to $AD = BC$.
However: the proof of that proposition contains a (rather subtle) mistake, explained in the article.
So summarizing: Euclid's proof of proposition 20 is wrong, but the gap is not the glaring oversight that I call out in the original post (which is covered by using a different definition of proportionality) but a more subtle one in the proof of the previous proposition that asserts that the two definitions are equivalent. As the article points out: they are equivalent for natural numbers, but not in more general contexts where Euclid's would be proof would still apply.
The authors of the article propose a way of 'fixing' the proof of proposition 19 using an interesting consequence of the Euclidean algorithm (that also appears in Euclid book VII), namely that every common divisor of two numbers is also a divisor of their greatest common divisor.
However when one is 'merely' interested in fixing proposition 20 instead, I think the argument in the other answer is much simpler (using division with remainder, which is of course the main ingredient of Euclid's algorithm, directly rather than indirectly).
A: In this answer, Bill Dubuque gives a proof of the proposition (which he calls 'unique fractionization' to stress the equivalence to unique factorization - a very good name I think) that does not rely on unique factorization but just on division with remainder.
When I translate that argument to the language of the video above we see it is very close and uses largely the same ingredients but there is a crucial difference: the points $G$ and $H$ are drawn on the lines $A$ and $B$ rather than on the shorter two. I spell out the argument below.
My (followup) question is:
Could it be that this is what Euclid was saying and that the video and/or written sources it relies on mixed things up, or does the argument in the video also work and am I still missing something?
The proof. We start in the same way as the text in the right part of the screenshot:

*

*Firstly the ratio of $A$ to $CD$ is equal to $B$ to $EF$

*Assume $CD$ does not measure $A$. Therefor $CD$ is parts of $A$

*Thus $EF$ is also the same parts of $B$ that $CD$ is of $A$

*Therefor as many parts of there are of $A$ in $CD$, so many parts there are of $B$ in $EF$
Now here is where I 'part' from the original. I take $n$ the largest number of copies of $CD$ that fit into $A$. The second bullet states that $x := A - n CD$ is not zero. It is however smaller than $CD$.
Very interestingly, by the third bullet this same number $n$ is also the largest number of times that $EF$ fits into $B$ so the number $y = B - n EF$ (which is obviously an integer because it was created using subtraction rather than multiplication and division) must be smaller than $EF$.
In the screen-shot the endpoints of $A$ and $B$ have no names so I will call them $A_1, A_2$ and $B_1, B_2$ respectively.
Draw point $G$ on $A$ so that $A_1G = x$ and so $A_2G = n CD$.
Draw point $H$ on $B$ so that $B_1H = y$ and so $B_2H = n EF$.
We know that $A_1A_2 : B_1B_2 = CD:EF$ and since $A_2G = n CD$ and $B_2H = n EF$ we see that $A_2G : B_2H = CD : EF$ as well.
So we find:
$$A_1A_2 : B_1B_2 = A_2G : B_2H$$
from which it follows by an earlier proposition of Euclid (VII, prop 12) that the video uses as well at this stage in the same way (but applied to the other line segments)
That
$$A_1G : B_1H = A: B$$
But since we already saw that $A_1G < CD$ and $B_1H < EF$ and $CD, EF$ were supposed the smallest with the property of having ratio $A:B$ we get the desired contradiction as before.
