622{
623 if (frame_position > video->total_frames)
624 frame_position = video->total_frames;
625
626 if (video->frame_rate <= 0.0) {
627 set_error(
"Invalid frame rate for seeking");
628 return false;
629 }
630
631 AVStream*
stream = demux->get_stream(video->stream_index);
634 return false;
635 }
636
637 double target_seconds = static_cast<double>(frame_position) / video->frame_rate;
638 auto ts =
static_cast<int64_t
>(target_seconds / av_q2d(
stream->time_base));
639
640 if (!demux->seek(video->stream_index, ts)) {
642 return false;
643 }
644
645 video->flush_codec();
646 return true;
647}
Core::GlobalStreamInfo stream
void set_error(const std::string &msg) const