MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ seek()

bool MayaFlux::IO::VideoFileReader::seek ( const std::vector< uint64_t > &  position)
overridevirtual

Seek to a specific position in the file.

Parameters
positionTarget position in N-dimensional space.
Returns
true if seek was successful.

Implements MayaFlux::IO::FileReader.

Definition at line 578 of file VideoFileReader.cpp.

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 {
590 std::shared_lock lock(m_context_mutex);
591 if (!m_demux || !m_video || !m_video->is_valid()) {
592 set_error("Cannot seek: reader not open");
593 return false;
594 }
595 video = m_video;
596 demux = m_demux;
597 }
598
599 if (!seek_internal(demux, video, target_frame))
600 return false;
601
602 m_decode_head.store(target_frame);
603
604 auto vc = m_container_ref.lock();
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(
613 static_cast<uint64_t>(m_decode_batch_size),
614 total > target_frame ? total - target_frame : 0UL);
615
616 decode_batch(*vc, batch);
617
618 if (m_decode_head.load() < total)
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
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_ptr< VideoStreamContext > m_video
std::atomic< uint64_t > m_decode_head

References decode_batch(), m_container_ref, m_context_mutex, m_decode_batch_size, m_decode_head, m_demux, m_video, seek_internal(), set_error(), start_decode_thread(), and stop_decode_thread().

+ Here is the call graph for this function: