34 Data(
const LoopOffset &offset, AVFrameUPtr f,
const CodecContext &codecContext,
35 const PlaybackEngineObjectID &sourceID)
42 if (frame->pts != AV_NOPTS_VALUE)
43 startTime = codecContext.toTrackPosition(AVStreamPosition(frame->pts));
45 startTime = codecContext.toTrackPosition(
46 AVStreamPosition(frame->best_effort_timestamp));
48 if (
auto frameDuration = getAVFrameDuration(*frame)) {
49 duration = codecContext.toTrackDuration(AVStreamDuration(frameDuration));
52 if (codecContext.context()->codec_type == AVMEDIA_TYPE_AUDIO) {
53 if (frame->sample_rate)
54 duration = TrackDuration(qint64(1000000) * frame->nb_samples
55 / frame->sample_rate);
57 duration = TrackDuration(0);
60 const auto &avgFrameRate = codecContext.stream()->avg_frame_rate;
61 duration = TrackDuration(
62 mul(qint64(1000000), { avgFrameRate.den, avgFrameRate.num })