Answer
Ball 1 was moving to the right at a speed of 4 m/s while ball 2 was moving to the left at a speed of 2 m/s.
Work Step by Step
The speeds of the two balls are too small relative to the speed of light so we can use the Galaian transformation formulas for speeds.
Now we need to identify the frames. Let $\rm S$ be the frame of the ground, and $\rm S'$ is the frame of the second ball (ball 2) which has a final speed of 4 m/s to the right. And ball 1 here is the first ball which has a final speed to the left of 2 m/s.
We know that ball 1 final speed is 2 m/s to the left relative to $\rm S$ while the speed of ball 2 is 4 m/s to the right relative to the same frame.
So, we can say that the speed of ball 1 relative to frame $\rm S'$ is -6 m/s while the speed of ball 2 is 0 m/s since the frame itself is stationary.
Now the collision occurs on frame $\rm S'$ where $v'_{f2}=0$ m/s, and $v'_{f1}=-6$ m/s.
The collision is perfectly elastic, so the momentum and the energy are conserved.
$$p_i=p_f$$
$$v'_{i1}m_1+v'_{i2}m_2=v'_{f1}m_1+v'_{f2}m_2$$
$m$ cancels since the two balls are identical
$$v'_{i1} +v'_{i2} =v'_{f1} +v'_{f2} $$
Plug the known;
$$v'_{i1} +v'_{i2} =-6 +0$$
$$v'_{i1} +v'_{i2} =-6\tag 1$$
$$E_i=E_f$$
$$\frac{1}{2}m_1(v'_{i1})^2+\frac{1}{2}m_2(v'_{i2})^2=\frac{1}{2}m_1(v'_{f1})^2+\frac{1}{2}m_2(v'_{f2})^2$$
Plug the known; $\frac{1}{2}m$ cancels,
$$ (v'_{i1})^2+ (v'_{i2})^2= (-6)^2+0$$
$$ (v'_{i1})^2+ (v'_{i2})^2=36\tag 2$$
Solving (1) for $v'_{i1}$, and plug into (2)
$$ ( -6-v'_{i2})^2+ (v'_{i2})^2=36 $$
$$ 36+12v'_{i2}+(v'_{i2})^2+ (v'_{i2})^2=36 $$
$$ 2(v'_{i2})^2+12v'_{i2}=0$$
$$ v'_{i2}[2 v'_{i2} +12]=0$$
whether $ v'_{f2}=0$, which is not realistic here, or
$$ v'_{i2} =\bf -6\;\rm m/s$$
and hence, plug into (1),
$$ v'_{i1} =\bf0\;\rm m/s$$
Now let's go back to frame $\rm S$, by using the Galilean transformations of velocity again.
$$v_{i1}=v_{i1}'+4=0+4 $$
$$v_{i1}=\color{red}{\bf +4}\;\rm m/s $$
and
$$v_{i2}=v_{i2}'+4=-6+4 $$
$$v_{i2}=\color{red}{\bf -2}\;\rm m/s $$
Therefore, ball 1 was moving to the right at a speed of 4 m/s while ball 2 was moving to the left at a speed of 2 m/s.