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

◆ extract_chapter_regions()

std::vector< FileRegion > MayaFlux::IO::FFmpegDemuxContext::extract_chapter_regions ( ) const

Extract chapter information as FileRegion entries.

Returns
Vector of FileRegion with type="chapter".

Definition at line 178 of file FFmpegDemuxContext.cpp.

179{
180 std::vector<FileRegion> regions;
181 if (!format_context)
182 return regions;
183
184 for (unsigned i = 0; i < format_context->nb_chapters; ++i) {
185 const AVChapter* ch = format_context->chapters[i];
186 FileRegion r;
187 r.type = "chapter";
188 r.name = "chapter_" + std::to_string(i);
189
190 AVDictionaryEntry* title = av_dict_get(ch->metadata, "title", nullptr, 0);
191 if (title)
192 r.name = title->value;
193
194 double tb = av_q2d(ch->time_base);
195 r.start_coordinates = { static_cast<uint64_t>(ch->start * tb * 1000) };
196 r.end_coordinates = { static_cast<uint64_t>(ch->end * tb * 1000) };
197 r.attributes["chapter_index"] = static_cast<int>(i);
198
199 regions.push_back(std::move(r));
200 }
201 return regions;
202}
AVFormatContext * format_context
Owned; freed in destructor.

References MayaFlux::IO::FileRegion::attributes, MayaFlux::IO::FileRegion::end_coordinates, format_context, MayaFlux::IO::FileRegion::name, MayaFlux::IO::FileRegion::start_coordinates, and MayaFlux::IO::FileRegion::type.