void MovieDecoder::decodeVideoFrame() { bool frameFinished = false; while (!frameFinished && getVideoPacket()) { frameFinished = decodeVideoPacket(); } if (!frameFinished) { qDebug() << "decodeVideoFrame() failed: frame not finished"; return; } }
void MovieDecoder::decodeVideoFrame() { bool frameFinished = false; while(!frameFinished && getVideoPacket()) { frameFinished = decodeVideoPacket(); } if (!frameFinished) { throw std::logic_error("decodeVideoFrame() failed: frame not finished"); } }
void MovieDecoder::seek(int timeInSeconds) { if (!allowSeek_) { return; } int64_t timestamp = AV_TIME_BASE * static_cast<int64_t>(timeInSeconds); if (timestamp < 0) { timestamp = 0; } int ret = av_seek_frame(pFormatContext_, -1, timestamp, 0); if (ret >= 0) { avcodec_flush_buffers(pFormatContext_->streams[videoStream_]->codec); } else { throw std::logic_error("Seeking in video failed"); } int keyFrameAttempts = 0; bool gotFrame = 0; do { int count = 0; gotFrame = 0; while (!gotFrame && count < 20) { getVideoPacket(); try { gotFrame = decodeVideoPacket(); } catch(std::logic_error&) {} ++count; } ++keyFrameAttempts; } while ((!gotFrame || !pFrame_->key_frame) && keyFrameAttempts < 200); if (gotFrame == 0) { throw std::logic_error("Seeking in video failed"); } }
int VideoDecoder::decodeVideoFrame() { int gotpkt = -1, decpkt = -1; while (((gotpkt = getVideoPacket()) == 0) && ((decpkt = decodeVideoPacket()) == 0)) { //empty } if (gotpkt < 0 || decpkt < 0) { return -1; } return 0; }
void MovieDecoder::seek(int timeInSeconds) { if (!m_AllowSeek) { return; } qint64 timestamp = AV_TIME_BASE * static_cast<qint64>(timeInSeconds); if (timestamp < 0) { timestamp = 0; } int ret = av_seek_frame(m_pFormatContext, -1, timestamp, 0); if (ret >= 0) { avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec); } else { qDebug() << "Seeking in video failed"; return; } int keyFrameAttempts = 0; bool gotFrame = 0; do { int count = 0; gotFrame = 0; while (!gotFrame && count < 20) { getVideoPacket(); gotFrame = decodeVideoPacket(); ++count; } ++keyFrameAttempts; } while ((!gotFrame || !m_pFrame->key_frame) && keyFrameAttempts < 200); if (gotFrame == 0) { qDebug() << "Seeking in video failed"; } }