Results 1 to 11 of 11

Thread: QT 4.4 / Phonon / Video / Rendering a single frame

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Default QT 4.4 / Phonon / Video / Rendering a single frame

    Hi, Is there any way to get individual frames of a video and render it as an image file?

    What I want to do is a video preview image(a jpg file for example) which gives an idea of what the video is about, like youtube preview.

    I'm pretty new to Qt Jambi and Phonon videoplayer, I have searched the API docs but still can't figure it out , any help will be appreciated, thanks ...

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Am not sure too.

    But u can try this -
    Pause the VideoPlayer / VideoWidget when u show the application.
    Its like seeking to frame 0 or time 0 and pausing. This will show the first frame.
    Then u can proceed with the play function

    hope i made sense :P

  3. #3
    Join Date
    Apr 2008
    Location
    Cluj-Napoca, Romania
    Posts
    10
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    hello,
    I 'm also trying to get an image from a videostream, i thought of using grabWidget on the video widget but it doesn't seem to capture anything from the video. I also tried to use pause on the media object, grab , then play (as suggested ).
    If anyone knows how to capture a frame please reply.

    Thank you,
    Titus

    Edited:
    Nevermind, it works just fine, it didn't like the place i made the videoWidget.
    Last edited by tituslup; 7th July 2008 at 13:50. Reason: updated contents

  4. #4
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    What do you mean by "didn't like the place I made the widget?" I'm trying to accomplish the same thing, but as of yet have not gotten it to work. All I get is a gray box the size of the widget. Thanks for any help you can give...

  5. #5
    Join Date
    Apr 2008
    Location
    Cluj-Napoca, Romania
    Posts
    10
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Hello JimDaniel,

    sorry for taking so long to answer you. I'll give you an example how i used the video Widget and the grabWidget:

    Qt Code:
    1. // this code is inside a class that inherits a QWidget
    2. m_MediaObject = new Phonon::MediaObject(this);
    3. m_MediaObject->clearQueue ();
    4. m_MediaObject->enqueue(Phonon::MediaSource(fileName)); // or setCurrentSource
    5. m_MediaObject->play();
    6.  
    7.  
    8. m_videoWidget = new Phonon::VideoWidget(this);
    9. m_videoWidget->setGeometry(0,0,500,500);
    10. Phonon::createPath(m_MediaObject, m_videoWidget);
    11.  
    12. m_videoWidget = new Phonon::VideoWidget(this);
    13. m_videoWidget->setGeometry(500,500,500,500);
    14. Phonon::createPath(m_MediaObject, m_videoWidget);
    15.  
    16. // if you want to grab the entire window
    17. //QPixmap ecran = QPixmap::grabWindow(QApplication::desktop()->winId());
    18. QPixmap image= QPixmap::grabWidget(this);
    19. image.save("printScreen.bmp");
    To copy to clipboard, switch view to plain text mode 

    Now, the thing is that i put there two video widgets, because for some reason i cant grab anything from the first one .The second one works fine, and i can grab the widget(image) and save it to a file or work with ... When the two videoWidgets are playing side by side, as in the case above, the video inside them is scaled differently in the widgets.

    I hope this helps you.
    Last edited by tituslup; 18th July 2008 at 09:14.

  6. The following user says thank you to tituslup for this useful post:

    JimDaniel (20th July 2008)

  7. #6
    JuanC Guest

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Quote Originally Posted by tituslup View Post
    Now, the thing is that i put there two video widgets, because for some reason i cant grab anything from the first one .The second one works fine, and i can grab the widget(image) and save it to a file or work with ... When the two videoWidgets are playing side by side, as in the case above, the video inside them is scaled differently in the widgets.
    I think there is a bug , you should submit a report about it :
    http://trolltech.com/trolltech/bugreport-form

  8. #7
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Thanks for responding. That does seem like a bug, but good you got it to work. I'll give it a try.

    Frustrated with the (current) limitations of phonon, I've decided to roll my own video class using the ffmpeg api. Its nearly done. When I'm finished I'll post it here in case anyone else wants to use it.

  9. #8
    Join Date
    May 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Please do. I am also looking to capture individual frames from a video file.

  10. #9
    Join Date
    Oct 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    I would also be interested in it.

  11. #10
    Join Date
    Jan 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    For my projects I also need individual frame decoding, and also video encoding.

    Eventually, I wrote an FFmpeg wrapper for QT4. You can find it here: http://code.google.com/p/qtffmpegwrapper

    It provides two classes: QVideoEncoder and QVideoDecoder. Frames are passed as QImage to/from the encoder/decoder. Any video format supported by FFmpeg is supported.

    There could be a few more exposed functions, but for me it does the job.

    Modified BSD license.

  12. #11
    Join Date
    Nov 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4 / Phonon / Video / Rendering a single frame

    Hi ,
    I was trying to your code. I have Window XP and I am using Visial Studio 2005. I can build the soluton but when try to run the code, i get the following exception after this line in your QVideoDecoder.cpp. :
    ffmpeg::avcodec_init();
    Unhandled exception at 0x00011714 in QTVIDEOWRAPPER.exe: 0xC0000096: Privileged instruction.

    Please help. It will very useful for me if I can compile and run it properly.
    Thanks.
    Roy

Similar Threads

  1. [SOLVED] DirectShow Video Player Inside Qt
    By ToddAtWSU in forum Qt Programming
    Replies: 16
    Last Post: 3rd November 2011, 07:47
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.