ffmpeg: rework checks for the -t option.

This commit is based on libav's implementation and
makes sure to compare output timestamps together.
It also reduces the differences with avconv.

The changes to the test reference files are caused
by an additional packet at the end, the timestamp
of the frame encoded by this packet is always
strictly below the limit stated by the -t option.
