Skip to content
Snippets Groups Projects
Commit daa247f6 authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin
Browse files

media: fix file streaming


File streaming emulates the frame rate and needs the unscaled
timestamps.

Change-Id: If712062d263c7c2110a72056b889ef3a4d1e51df
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 563e274a
No related branches found
No related tags found
No related merge requests found
......@@ -290,6 +290,7 @@ MediaDecoder::decode(VideoFrame& result)
}
}
#endif
auto emulationTimestamp = frame->pts;
if (frame->pts != AV_NOPTS_VALUE)
frame->pts = av_rescale_q(frame->pts - avStream_->start_time, avStream_->time_base, decoderCtx_->time_base);
......@@ -306,8 +307,8 @@ MediaDecoder::decode(VideoFrame& result)
rec->recordData(frame, true, true);
}
if (emulateRate_ and frame->pts != AV_NOPTS_VALUE) {
auto frame_time = getTimeBase()*(frame->pts - avStream_->start_time);
if (emulateRate_ and emulationTimestamp != AV_NOPTS_VALUE) {
auto frame_time = getTimeBase()*(emulationTimestamp - avStream_->start_time);
auto target = startTime_ + static_cast<std::int64_t>(frame_time.real() * 1e6);
auto now = av_gettime();
if (target > now) {
......@@ -359,6 +360,7 @@ MediaDecoder::decode(const AudioFrame& decodedFrame)
if (frameFinished) {
av_packet_unref(&inpacket);
auto emulationTimestamp = frame->pts;
if (frame->pts != AV_NOPTS_VALUE)
frame->pts = av_rescale_q(frame->pts, avStream_->time_base, decoderCtx_->time_base);
......@@ -374,8 +376,8 @@ MediaDecoder::decode(const AudioFrame& decodedFrame)
rec->recordData(frame, false, true);
}
if (emulateRate_ and frame->pts != AV_NOPTS_VALUE) {
auto frame_time = getTimeBase()*(frame->pts - avStream_->start_time);
if (emulateRate_ and emulationTimestamp != AV_NOPTS_VALUE) {
auto frame_time = getTimeBase()*(emulationTimestamp - avStream_->start_time);
auto target = startTime_ + static_cast<std::int64_t>(frame_time.real() * 1e6);
auto now = av_gettime();
if (target > now) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment