If the ejaculation happens accidentally without any deliberate attempt on your part, then it does not break the fast. However, the fast is broken, if it has been because of our own willful actions such as contemplation of sexual activity or watching such scenes or flirting, etc.
It is important for us to know that fasting is not simply refusing to eat and drink; rather, it is much more than that: It involves refraining from all sinful thoughts, words and actions by practicing self-restraint.
The Prophet (peace be upon him) said, "Whoever does not give up foul speech and lewd acts, while fasting, Allah has no of him to go without food and drink." He also said, "Fasting is a shield as long as a person does not break it." By breaking the shield he meant indulging in evil thoughts and actions.