Do not look at the intervals, look only at their ends.
You have a bunch of starting moments and a bunch of ending moments. Imagine that starting moments are red and ending moments are blue. Or imagine that starting moments are opening braces and ending moments are closing braces.
Put them all together in a list. Sort the list from earliest to latest, ignoring the colour.
Now take a counter set to zero with you, and walk down the list. When you see a red moment, increment the counter. When you see a blue moment, decrement the counter. When the counter value goes from 0 to 1, output "start" and the current time. When the counter value goes from 1 to 0, output "end" and the current time. If the counter value drops below 0, output "Houston, we have a problem". You should end with your counter at 0 and a bunch of nice non-overlapping intervals.
This is the good old brace counting algorithm.
Illustration.
A bunch of overlapping intervals:
(-------------------)
(----------------------)
(---)
(---------------------)
(-----------------)
A bunch of interval ends:
(-----(-------------)-(-----)----------------) (----(---)--------)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…