Seek to a specific position in the file.
579{
580 if (position.empty())
581 return false;
582
583 const uint64_t target_frame = position[0];
584
586
587 std::shared_ptr<VideoStreamContext> video;
588 std::shared_ptr<FFmpegDemuxContext> demux;
589 {
592 set_error(
"Cannot seek: reader not open");
593 return false;
594 }
597 }
598
600 return false;
601
603
605 if (!vc)
606 return true;
607
608 vc->invalidate_ring();
609 vc->set_read_position({ target_frame });
610
611 const uint64_t total = vc->get_total_source_frames();
612 const uint64_t batch = std::min(
614 total > target_frame ? total - target_frame : 0UL);
615
617
620
621 return true;
622}
uint64_t decode_batch(Kakshya::VideoFileContainer &vc, uint64_t batch_size)
Decode up to batch_size frames starting at m_decode_head.
void set_error(const std::string &msg) const
void start_decode_thread()
uint32_t m_decode_batch_size
std::weak_ptr< Kakshya::VideoFileContainer > m_container_ref
std::shared_ptr< FFmpegDemuxContext > m_demux
bool seek_internal(const std::shared_ptr< FFmpegDemuxContext > &demux, const std::shared_ptr< VideoStreamContext > &video, uint64_t frame_position)
std::shared_mutex m_context_mutex
std::shared_ptr< VideoStreamContext > m_video
void stop_decode_thread()
std::atomic< uint64_t > m_decode_head