Hey, I am creating videoplayer that also tracks frame count, the problem I came to is when I change my videorate using
g_object_set(videorate, "rate", newPlayRate, nullptr);
My frames are updated in this way:
If before update it was 100/500, now its 100/1000, I understand frames are doubled, but why wouldnt current frame position double as well. I wanted to fix this just using 100*(1/newPlayRate), but the problem comes when we seek, because after the seek frames would show correctly as 200/1000, with my new change of adding playrate its now 400/1000.
Seek code:
void HttpVideoPlayer::seekToFrame(gint64 seekTime) {
qDebug() << "Seeking to frame at time:" << seekTime;
if (seekTime < 0) seekTime = 0;
if (pipeline) {
gst_element_seek_simple(pipeline, GST_FORMAT_TIME,
static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_ACCURATE), seekTime);
}
}
MaxFrame and Current Frame code:
gint64 HttpVideoPlayer::getCurrentFrame() {
if (pipeline) {
gint64 current;
gst_element_query_position(pipeline, GST_FORMAT_TIME, ¤t);
return current * fps / GST_SECOND;
}
return 0;
}
gint64 HttpVideoPlayer::getMaxFrame() {
if (pipeline) {
gint64 duration = 0;
gst_element_query_duration(pipeline, GST_FORMAT_TIME, &duration);
return duration * fps / GST_SECOND;
}
return 0;
}