|
@@ -91,17 +91,23 @@ void DecodeVedio::stopDecodeVedio()
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ * @brief 设置当前播放位置,单位是微秒
|
|
|
+ * 这里需要去掉队列中已有的图片数目对应的时长
|
|
|
+ *
|
|
|
+ * @param pos
|
|
|
+ */
|
|
|
void DecodeVedio::setCurrentPos(quint64 pos)
|
|
|
{
|
|
|
-
|
|
|
- qint64 target_pos = m_startPos + pos;
|
|
|
- SPDLOG_DEBUG("设置播放位置:{}",target_pos);
|
|
|
+
|
|
|
|
|
|
m_pauseDecode = true;
|
|
|
-
|
|
|
+
|
|
|
+ int queueNumFPS = m_queueImage.count() * 1000.0 / m_fps;
|
|
|
+ qint64 target_pos = m_startPos + pos - queueNumFPS;
|
|
|
+ SPDLOG_DEBUG("设置播放位置:{}",target_pos);
|
|
|
|
|
|
- int ret = av_seek_frame(m_pFormatContext, -1, target_pos, AVSEEK_FLAG_ANY);
|
|
|
+ int ret = av_seek_frame(m_pFormatContext, -1, target_pos, AVSEEK_FLAG_BACKWARD);
|
|
|
if(ret < 0)
|
|
|
{
|
|
|
SPDLOG_WARN("跳转失败...");
|
|
@@ -119,10 +125,11 @@ void DecodeVedio::setCurrentPos(quint64 pos)
|
|
|
|
|
|
}
|
|
|
m_mutexQueue.unlock();
|
|
|
- SPDLOG_INFO("跳转完成 , queue {}", m_queueImage.count());
|
|
|
+ m_condQueueNoFull.wakeAll();
|
|
|
+ SPDLOG_INFO("跳转完成 , queue count {}", m_queueImage.count());
|
|
|
|
|
|
m_pauseDecode = false;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -204,13 +211,12 @@ int DecodeVedio::getFrameCount()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- int fps = 0;
|
|
|
|
|
|
enum AVCodecID codecID = pFormatCtx->streams[videoStreamIndex]->codecpar->codec_id;
|
|
|
if (codecID == AV_CODEC_ID_HEVC)
|
|
|
{
|
|
|
SPDLOG_DEBUG("视频格式是HEVC");
|
|
|
- fps = -2;
|
|
|
+ m_fps = -2;
|
|
|
|
|
|
|
|
|
|
|
@@ -236,16 +242,16 @@ int DecodeVedio::getFrameCount()
|
|
|
SPDLOG_DEBUG("视频格式是H.264");
|
|
|
|
|
|
AVRational frameRate = pFormatCtx->streams[videoStreamIndex]->avg_frame_rate;
|
|
|
- fps = frameRate.num*1.0 / frameRate.den;
|
|
|
+ m_fps = frameRate.num*1.0 / frameRate.den;
|
|
|
|
|
|
}else
|
|
|
{
|
|
|
- fps = 30;
|
|
|
+ m_fps = 30;
|
|
|
}
|
|
|
|
|
|
avformat_close_input(&pFormatCtx);
|
|
|
|
|
|
- return fps;
|
|
|
+ return m_fps;
|
|
|
}
|
|
|
|
|
|
void DecodeVedio::setVideoSize(int width, int height)
|