36 Data(
const LoopOffset &offset, AVFrameUPtr f,
const CodecContext &codecContext, quint64 sourceId)
43 if (frame->pts != AV_NOPTS_VALUE)
44 startTime = codecContext.toTrackPosition(AVStreamPosition(frame->pts));
46 startTime = codecContext.toTrackPosition(
47 AVStreamPosition(frame->best_effort_timestamp));
49 if (
auto frameDuration = getAVFrameDuration(*frame)) {
50 duration = codecContext.toTrackDuration(AVStreamDuration(frameDuration));
53 if (codecContext.context()->codec_type == AVMEDIA_TYPE_AUDIO) {
54 if (frame->sample_rate)
55 duration = TrackDuration(qint64(1000000) * frame->nb_samples
56 / frame->sample_rate);
58 duration = TrackDuration(0);
61 const auto &avgFrameRate = codecContext.stream()->avg_frame_rate;
62 duration = TrackDuration(
63 mul(qint64(1000000), { avgFrameRate.den, avgFrameRate.num })