Access video frames from QMediaPlayer to apply online/ofline image filters to frames
-
Hi,
I would like to implement a feature which applies a custom filter to all frame images of a video and then stores the altered video to file. This is offline filtering, meaning that no camera is involved and videos are loaded from stored media files and should be stored to a file with the custom filter(s) applied to video frames.I implemented code which which loads a video to
QMediaPlayer
(with video output being eitherQGraphicsVideoItem
or alternativelyQVideoWidget
, than through someQPushButton::pressed
(and GUI check box selection of a filter to be applied) calls a slotFileManipulator::createFilteredVideo()
. I got this far.Now: This slot should then call
QMediaPlayer::play()
and connect a custom image filter slotMyFilter::applyFilter()
to a signal emited by aQMediaPlayer signal
or something likeQVideoProbe::videoFrameProbed(QVideoFrame)
(I knowQVideoProbe
does not exist any more in Qt6 and besides it wouldn't have done the job as it only monitored video frames but as I dont know any other helpful classes, I am mentioning it as an example) soMyFilter::applyFilter()
can than filter the image and send it back for displaying live in GUI and at the same time (in a different thread instance) save a copy of the video to a file (with audio signal being unchanged, same as before and video being altered by the filter).I realize this is a very general question which an be divided in at least 2 problems
-
apply an online filter to video and display the filtered video live with the GUI
-
apply an offline image filter to each frame of a video file and store altered video to file.
so I am just fishing for useful Qt classes and signals/slots which I can study and learn about to get going on this topic.
I thank you up front for your inspiration.
-
-
Hi,
You should go with Qt6, the new QtMultimedia module is better suited for what you want to do.
Check the QVideoSink class and friends.