void WindowManager::applyScale() { const int scale = config.getIntValue("scale"); if (mainGraphics->getScale() == scale) return; mainGraphics->setScale(scale); resizeVideo(mainGraphics->mActualWidth, mainGraphics->mActualHeight, true); }
void WindowManager::doResizeVideo(const int actualWidth, const int actualHeight, const bool always) { if (!always && mainGraphics->mActualWidth == actualWidth && mainGraphics->mActualHeight == actualHeight) { return; } #ifdef __native_client__ naclPostMessage("resize-window", strprintf("%d,%d", actualWidth, actualHeight)); #else // __native_client__ resizeVideo(actualWidth, actualHeight, always); #endif // __native_client__ }
void VLCVideoTextureObjChunk::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if (0x0000 != (whichField & UrlFieldMask)) { // init VLC internal structures if (getUrl().length() > 0) { createVLCInstance(); } } else if ((0x0000 != (whichField & WidthFieldMask)) || (0x0000 != (whichField & HeightFieldMask))) { // reinit VLC internal structures if (getUrl().length() > 1) { resizeVideo(); } } if (0x0000 != (whichField & StatusFieldMask)) { // update VLC } if (0x0000 != (whichField & TimestampFieldMask)) { // update VLC if (getUrl().length() > 1) { if (!this->getIsMaster()) { updateTime(); } } } }
void WidgetRenderer::resizeEvent(QResizeEvent *e) { resizeVideo(e->size()); update(); }
void rphLabelEx::resizeEvent ( QResizeEvent * event ) { emit resizeVideo(event->size().width(),event->size().height()); }
// update() has only to deal with the faders in all videos, and (re)set positions and sizes of video windows. void StelVideoMgr::update(double deltaTime) { for (auto voIter = videoObjects.constBegin(); voIter != videoObjects.constEnd(); ++voIter) { QMediaPlayer::MediaStatus mediaStatus = (*voIter)->player->mediaStatus(); QString id=voIter.key(); // Maybe we have verbose as int with levels of verbosity, and output the next line with verbose>=2? if (verbose) qDebug() << "StelVideoMgr::update() for" << id << ": PlayerState:" << (*voIter)->player->state() << "MediaStatus: " << mediaStatus; // fader must be updated here, else the video may not be visible when not yet fully loaded? (*voIter)->fader.update((int)(deltaTime*1000)); // It seems we need a more thorough analysis of MediaStatus! // In all not-ready status we immediately leave further handling, usually in the hope that loading is successful really soon. switch (mediaStatus) { case QMediaPlayer::UnknownMediaStatus: case QMediaPlayer::NoMedia: case QMediaPlayer::InvalidMedia: case QMediaPlayer::LoadingMedia: case QMediaPlayer::StalledMedia: if (verbose) qDebug() << "StelVideoMgr::update(): " << id << mediaStatus << "\t==> no further update action"; continue; case QMediaPlayer::LoadedMedia: case QMediaPlayer::BufferingMedia: case QMediaPlayer::BufferedMedia: case QMediaPlayer::EndOfMedia: default: break; } // if (verbose) // qDebug() << "update() Still alive"; // First fix targetFrameSize if needed and possible. if ((*voIter)->needResize && ((*voIter)->resolution.isValid())) { // we have buffered our final size (which may be relative to screen size) in targetFrameSize. So, simply resizeVideo(voIter.key(), (*voIter)->targetFrameSize.width(), (*voIter)->targetFrameSize.height()); } // if keepVisible, pause video if already close to end. if ((*voIter)->simplePlay) { if ( ((*voIter)->keepVisible) && ((*voIter)->duration > 0) && ((*voIter)->player->position() >= ((*voIter)->duration - 250)) ) { if (verbose) qDebug() << "update(): pausing" << id << "at end"; (*voIter)->player->pause(); } continue; } if ((*voIter)->player->state()==QMediaPlayer::StoppedState) continue; // the rest of the loop is only needed if we are in popup playing mode. QSizeF currentFrameSize= (*voIter)->fader.getInterstate() * (*voIter)->targetFrameSize; QPointF frameCenter= (*voIter)->popupOrigin + ( (*voIter)->popupTargetCenter - (*voIter)->popupOrigin ) * (*voIter)->fader.getInterstate(); QPointF frameXY=frameCenter - 0.5*QPointF(currentFrameSize.width(), currentFrameSize.height()); (*voIter)->videoItem->setPos(frameXY); (*voIter)->videoItem->setSize(currentFrameSize); if (verbose) qDebug() << "StelVideoMgr::update(): Video" << id << "at" << (*voIter)->player->position() << ", player state=" << (*voIter)->player->state() << ", media status=" << (*voIter)->player->mediaStatus(); int newPos=(*voIter)->player->position(); // if ((newPos==(*voIter)->lastPos) && ((*voIter)->player->state()==QMediaPlayer::PlayingState)) // { // // I (GZ) have no idea how this can happen, but it does, every couple of runs. // // I see this happen only in the grow-while-play phase, but I see no logical error. // // It seemed to indicate not-fully-loaded, but this would have been caught in the intro test. // // But this even can happen if MediaStatus==BufferedMedia, i.e. fully loaded. Really a shame! // // TODO: check with every version of Qt whether this can still happen. // // SILLY! Of course if Stellarium framerate > video framerate... // if (verbose) // { // qDebug() << "StelVideoMgr::update(): player state" << (*voIter)->player->state() << "with MediaStatus" << mediaStatus; // qDebug() << "This should not be: video should play but position" << newPos << "does not increase? Bumping video."; // } // //(*voIter)->player->stop(); // GZ Dec2: Do we really need to stop? // (*voIter)->player->setPosition(newPos+1); // GZ Dec2 flipped 2 lines. // (*voIter)->player->play(); // qDebug() << "We had an issue with a stuck mediaplayer, should play again!"; // } (*voIter)->lastPos=newPos; if (verbose) qDebug() << "StelVideoMgr::update(): fader at " << (*voIter)->fader.getInterstate() << "; update frame size " << currentFrameSize << "to XY" << frameXY; // if we want still videos during transition, we must grow/shrink paused, and run only when reached full size. // We must detect a frame close to end, pause there, and trigger the fader back to 0. if ((*voIter)->keepVisible) { if ((*voIter)->fader.getInterstate()==0.0f) { // interstate is >0 on startup, so 0 is reached only at end of loop. we can send stop here. (*voIter)->player->stop(); // this immediately hides the video window. (*voIter)->simplePlay=true; // to reset (*voIter)->keepVisible=false; } else if ((*voIter)->fader.getInterstate()<1.0f) { if (verbose) qDebug() << "StelVideoMgr::update(): not fully grown: pausing video at start or end!"; (*voIter)->player->pause(); } else if (((*voIter)->duration > 0) && ((*voIter)->player->position() >= ((*voIter)->duration - 250))) // allow stop 250ms before end. 100ms was too short! { if (verbose) qDebug() << "StelVideoMgr::update(): position " << (*voIter)->player->position() << "close to end of duration " << (*voIter)->duration << "--> pause and shutdown with fader "; (*voIter)->player->pause(); // TBD: If we set some very last frame position here, it takes a very long while to seek (may disturb/flicker!) // (*voIter)->player->setPosition((*voIter)->duration-10); (*voIter)->fader=false; // trigger shutdown (sending again does not disturb) } else if (((*voIter)->player->state() != QMediaPlayer::PlayingState)) { if (verbose) qDebug() << "StelVideoMgr::update(): fully grown: play!"; (*voIter)->player->play(); } } // If the videos come with their own fade-in/-out, this can be played during transitions. (keepVisible configured to false) // In this case we must trigger shrinking *before* end of video! else { if ((*voIter)->fader.getInterstate()>0.0f) { if (((*voIter)->player->state() != QMediaPlayer::PlayingState)) (*voIter)->player->play(); if (( ((*voIter)->duration > 0) && ((*voIter)->player->position() >= ((*voIter)->duration - (*voIter)->fader.getDuration() - 200)))) { if (verbose) qDebug() << "StelVideoMgr::update(): position " << (*voIter)->player->position() << "close to end of duration " << (*voIter)->duration << "minus fader duration " << (*voIter)->fader.getDuration() << "--> shutdown with fader "; (*voIter)->fader=false; // trigger shutdown (sending again does not disturb) } } else // interstate==0: end of everything. { if (verbose) qDebug() << "StelVideoMgr::update(): Stopping at Interstate " << (*voIter)->fader.getInterstate(); (*voIter)->player->stop(); // immediately hides video window. (*voIter)->simplePlay=true; // reset } } } }
int main( void ) { help(); // func type int funcType = 1; int processId = 0; // paramater int layerLimit = 3; int widthDeletedDefault = 70; int colorDiffThred = 5; int elePerTagThred = 300; int bandWidthDefault = 50; int keyFrameNumLimit = 30; int badCutLimit = (int)(0.08 * widthDeletedDefault); vector<int> shotArr; switch ( funcType ) { case 0:{ bool state; state = video2Frames( processId ); if ( !state ) return -2; // shot Cut cout << " Shot Cut --ING" << endl; segShotCut( shotArr ); cout << " Convert Process Finished !! " << endl; } case 1:{ int globalTime = clock(); getShotCut( shotArr ); // resize shot for ( int shotId = 1; shotId < (int)shotArr.size(); shotId++ ) { int frameStId = shotArr[shotId - 1]; int frameEdId = shotArr[shotId]; cout << " Process Shot From " << frameStId << " To " << frameEdId << " --ING" << endl << endl; // read frames vector<Mat> frames; bool state; state = readFrameStream( frameStId, frameEdId, frames ); if ( !state ) return -2; // calculate Energy vector<Mat> pixelEnergy; vector<int> pixelTag; int tagNum; calcPixelTag( frames, pixelTag, tagNum, colorDiffThred, elePerTagThred, frameStId ); calcPixelEnergy( frames, pixelTag, tagNum, pixelEnergy, frameStId ); // temporal compress vector<int> keyFrame; timeCompress( pixelEnergy, keyFrame, keyFrameNumLimit ); preserveKeyData( keyFrame, frames, pixelEnergy ); // resize Video int widthDeleted = widthDeletedDefault; vector<Mat> edgeProtect; for ( int c = 0; c < 2; c++ ) { if ( widthDeleted > 0 ) { calcEdgeProtect( frames, edgeProtect ); resizeVideo( keyFrame, frames, pixelEnergy, edgeProtect, layerLimit, widthDeleted, bandWidthDefault, badCutLimit, frameStId, frameEdId, c ); scaleVideo( keyFrame, frames, pixelEnergy, widthDeleted, frameStId, frameEdId, c ); rotateVideo( keyFrame, frames, pixelEnergy, frameStId, frameEdId, c ); } else { copyFrame( frameStId, frameEdId ); } } cout << endl; } // finished cout << " Shot Finished !! Well done !!" << endl; globalTime = clock() - globalTime; globalTime = (globalTime + 500) / 1000; printf( " Global Time Used : %d min %d sec\n", globalTime / 60, globalTime % 60 ); break; } case 2:{ // write frame stream writeFrameStream(); } case 3:{ // write video bool state = writeVideo( processId ); if ( !state ) return -2; break; } default: break; } system( "pause" ); return 0; }
void VideoRenderer::resizeVideo(const QSize &size) { resizeVideo(size.width(), size.height()); }