On Thursday 02 September 2010 04:50:48 ext Chris Meyer wrote:
> I am trying to grab individual frames out of a video using
> QMediaPlayer and QVideoGraphicsItem.
> 
> My general strategy is to pause() the player and then setPosition(n).
> Some time later, the frame will be available in the QVideoGraphicsItem
> and I can render it to a scene (and in turn a QImage).
> 
> The problem is determining when that frame is available.
> 
> First question: Is there any existing solution to this in the current code?

If it's necessary only to grab the video frames without displaying them,
it's possible to use the QVideoRendererControl directly without 
QGraphicsVideoItem. The performance should be better since it's not necessary 
to convert the scene to QImage but receive the frames data directly.

It's necessary to implement the video surface and pass it to QVideoRenderer 
control in the similar way to done in QGraphicsVideoItem.

Regards
  Dmytro.

> 
> If not, next question: Can that functionality be added?
> 
> My solution, which seems to work, is to add a frameChanged() signal to
> QVideoGraphicsItem that is emitted when _q_present() is called (see
> patch below).
> 
> Is this a reasonable solution?
> 
> If not, what are other ideas/directions?
> 
> Here's the trivial patch for 'frameChanged()':
> 
> diff --git a/src/multimedia/qgraphicsvideoitem.cpp
> b/src/multimedia/qgraphicsvideoitem.cpp
> index db1f299..14ddb99 100644
> --- a/src/multimedia/qgraphicsvideoitem.cpp
> +++ b/src/multimedia/qgraphicsvideoitem.cpp
> @@ -144,6 +144,8 @@ void QGraphicsVideoItemPrivate::_q_present()
>      } else {
>          q_ptr->update(boundingRect);
>      }
> +
> +    emit q_ptr->frameChanged();
>  }
> 
>  void QGraphicsVideoItemPrivate::_q_formatChanged(const
> QVideoSurfaceFormat &format)
> diff --git a/src/multimedia/qgraphicsvideoitem.h
> b/src/multimedia/qgraphicsvideoitem.h
> index a447f67..35425c9 100644
> --- a/src/multimedia/qgraphicsvideoitem.h
> +++ b/src/multimedia/qgraphicsvideoitem.h
> @@ -86,6 +86,7 @@ public:
> 
>  Q_SIGNALS:
>      void nativeSizeChanged(const QSizeF &size);
> +    void frameChanged();
> 
>  protected:
>      void timerEvent(QTimerEvent *event);
> _______________________________________________
> Qt-mobility-feedback mailing list
> [email protected]
> http://lists.trolltech.com/mailman/listinfo/qt-mobility-feedback
_______________________________________________
Qt-mobility-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-mobility-feedback

Reply via email to