Do someone know how to get a snapshot of a video in Qt?
Do someone know how to get a snapshot of a video in Qt?
For video that's not played I can think only of ffmpeg.
For video that's played use Phonon and grabWidget()
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
You didn't give enough information to answer your question.
Do you have access to the frame data?
If so, its easy.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
wshn13 (29th July 2011)
how about using open cv library??
If You don't want create Your solution, use the ready one, i.e.:
lib: vlc, ffmpeg
another prog.: ffmpeg
For lib go into vlc/ffmpeg page and dll src. But You will face some library licensing restriction.
For ffmpeg use QProcess, send time infromation and output file path.
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
With OpenCV its just few lines of code (for RGB24 images). This will extract frame number frameNo from video and convert to QImage:
To work with other image formats, you will have to do some direct pixel manipulation.Qt Code:
QString pathToVideo = ... CvCapture * capture = cvCaptureFromAVI( pathToVideo.toAscii(),constData() ); cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, frameNo); IplImage * cvimg = cvQueryFrame(capture); if(cvimg){ // this will be NULL if you specify invalid frame index } cvReleaseCapture(&capture);To copy to clipboard, switch view to plain text mode
Well I can't actually post any code for you, but You should look for either libVLC (VideLan - C=code) or AFAIK libavcodec (part of FFmpeg):
http://wiki.videolan.org/LibVLC
http://ffmpeg.org/download.html
use those libraries to retrieve the data.
In case of FFmpeg carefully read license because there is a loot of licensed stuff so ...
Most easiest cross-platform way of doing this task (excluding grabWindow()) is to use ffmpeg. Download ffmpeg (binaries) for Your platform and use QProcess to capture "screenshot" (ffmpeg -s). Then read that file into i.e. QImage and with minimum work You have a screen-shoot taking capable program of the video at particular time (defined earlier)
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
Well... check this cmd:
it's working for me.Qt Code:
ffmpeg -y -i "f:\path\to\movies" -ss "00:02:12.0" -vcodec mjpeg -vframes 1 -s 1280x720 "c:\picture.jpg"To copy to clipboard, switch view to plain text mode
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
I modify you cmd like this: ffmpeg -y -i "/home/wshn13/MyDocs/Video/a.avi" -ss "00:02:12.0" -vcodec mjpeg -vframes 1 -s 1280x720 "/home/wshn13/picture.jpg"
but a error accur to me says /home/wshn13/MyDocs/Video/a.avi: Invalid data found when processing input
I don't know why
Are You sure that a.avi is actually valid AVI file? Does it has length > 2min 12 sec?
Clearly this is error either Your or yours ffmpeg so please look in google how to grab frames using ffmpeg tool.
Psted by me cmd line works fine.
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
Bookmarks