+ let actual_time = track.seek(cur_pts, time)?;
+ match track.stream_type {
+ StreamType::Video => vpts = Some(actual_time),
+ StreamType::Audio => apts = Some(actual_time),
+ _ => {},
+ };
+ }
+ /* For audio+video stream case when the post-seek actual times differ
+ by more than half a second try to seek audio to a closer position
+ to video.
+ */
+ if let (true, Some(vtime), Some(atime)) = (self.tracks.len() == 2, vpts, apts) {
+ if vtime.max(atime) - vtime.min(atime) > 500 && atime != 0 {
+ for track in self.tracks.iter_mut() {
+ if track.stream_type == StreamType::Audio {
+ let new_pts = NATimeInfo::time_to_ts(vtime, 1000, track.tb_num, track.tb_den);
+ track.seek(new_pts, NATimePoint::Milliseconds(vtime))?;
+ }
+ }
+ }