Results 1 to 2 of 2

Thread: unable to play gstreamer in QWidget

  1. #1
    Join Date
    Oct 2013
    Location
    Bangalore,India
    Posts
    64
    Thanks
    21
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default unable to play gstreamer in QWidget

    I am trying to use gstreamer to play video from a network camera in QWidget.
    I am utilizing "mjpeg" stream of the camera.

    I am able to successfully play the video in terminal using :
    Qt Code:
    1. gst-launch souphttpsrc location=http://169.254.75.39/video2.mjpg timeout=5 ! jpegdec ! xvimagesink
    To copy to clipboard, switch view to plain text mode 

    The same code I am trying to play in QWidget using this code:
    Qt Code:
    1. #include <glib.h>
    2. #include <gst/gst.h>
    3. #include <gst/interfaces/xoverlay.h>
    4.  
    5. #include <QApplication>
    6. #include <QTimer>
    7. #include <QWidget>
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. if (!g_thread_supported ())
    12. g_thread_init (NULL);
    13.  
    14. gst_init (&argc, &argv);
    15. QApplication app(argc, argv);
    16. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
    17.  
    18. // prepare the pipeline
    19.  
    20. GstElement *pipeline = gst_pipeline_new ("xvoverlay");
    21. GstElement *src = gst_element_factory_make ("souphttpsrc",NULL);
    22. GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
    23. gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
    24. gst_element_link (src, sink);
    25. g_object_set (src, "location", "http://169.254.75.39/video2.mjpg", NULL);
    26. // prepare the ui
    27.  
    28. QWidget window;
    29. window.move(0,0);
    30. window.resize(320, 240);
    31. window.show();
    32.  
    33. WId xwinid = window.winId();
    34. gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
    35.  
    36. // run the pipeline
    37.  
    38. GstStateChangeReturn sret = gst_element_set_state (pipeline,
    39. GST_STATE_PLAYING);
    40. if (sret == GST_STATE_CHANGE_FAILURE) {
    41. gst_element_set_state (pipeline, GST_STATE_NULL);
    42. gst_object_unref (pipeline);
    43. // Exit application
    44. QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
    45. }
    46.  
    47. int ret = app.exec();
    48.  
    49. window.hide();
    50. gst_element_set_state (pipeline, GST_STATE_NULL);
    51. gst_object_unref (pipeline);
    52.  
    53. return ret;
    54. }
    To copy to clipboard, switch view to plain text mode 

    When I run the code,all I am getting is a blank QWidget with nothing.

    My gstreamer has been correctly setup in QT and I was able to play a sample pattern easily in QWidget.

    I guess I am missing the decoder configuration in QT for 'jpegdec'
    Can anyone tell how to correctly set it up?
    Here is the .pro file content:
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = streaming
    4. TEMPLATE = app
    5.  
    6.  
    7. SOURCES += main.cpp\
    8. mainwindow.cpp
    9.  
    10. HEADERS += mainwindow.h
    11.  
    12. FORMS += mainwindow.ui
    13.  
    14. CONFIG += link_pkgconfig
    15. PKGCONFIG += gstreamer-0.10\
    16. gstreamer-interfaces-0.10\
    17. gtk+-2.0\
    18.  
    19. QMAKE_CXXFLAGS += -fpermissive
    To copy to clipboard, switch view to plain text mode 

    P.S. : using ubuntu 12.04

  2. #2
    Join Date
    Jul 2015
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: unable to play gstreamer in QWidget

    I am also looking for the answer. Have you got any solution?

Similar Threads

  1. Replies: 0
    Last Post: 19th November 2012, 11:02
  2. Unable to play RTSP video in Qt media player demo
    By sandeep.theartist in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2012, 16:47
  3. Unable to play audio outside Qt creator
    By somnathbanik in forum Newbie
    Replies: 0
    Last Post: 9th November 2010, 07:47
  4. Play video file with Phonon and GStreamer show black screen
    By SimbadSubZero in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2010, 12:47
  5. Unable to play gif files
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 24th March 2006, 20:24

Tags for this Thread

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.