Let the time they both travel be x hours.
By the time they both meet, the distance covered by both would be equal to the width of the river.
Distance = Speed*time
The 4 mph after x hours would have traveled = 4x
The 5 mph after x hours would have traveled = 5x
Total distance traveled = 4x + 5x = 3
9x = 3
x = 3/9
x = 1/3 hours = 1/3 * 60 minutes = 20 minutes
They would have both traveled 20 minutes as at when they meet.