microsoft / FFmpegInterop

This is a code sample to make it easier to use FFmpeg in Windows applications.
Apache License 2.0
1.29k stars 310 forks source link

Seek time validation check incorrectly failing for file with large start time offset #270

Closed brbeec closed 4 years ago

brbeec commented 4 years ago

In FFmpegInteropMSS::OnStarting() we have a sanity check to verify that the seek time doesn’t exceed the duration. However, the duration is start-time-based while the seek time is zero-based having already taken into account the start time offset. This can cause the check to incorrectly fail when the start time is not zero.

For example it's possible for a file’s start time to be larger than its duration. In this case the validation check will always fail since the seek time will always be greater than the duration.

This change moves the validation check prior to adjusting the seek time by the start time offset (i.e. when seek time is start-time-based like the duration).