Results 1 to 5 of 5

Thread: Best way to stream and record a webcam

  1. #1
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Best way to stream and record a webcam

    Hi all!

    I'm new to this forum, and also relatively new to Qt programming.

    I'm developing (or trying to develop) a instant messaging program with webcam support (this is essential). It has to be multiplatform and be able to record and stream the video to another PC in the same network.

    For now, I have working the chat part and the local webcam using the QCamera class from qt-mobility, but I don't know if this is the best way as it doesn't seem trivial how to stream it...

    I'm thinking to use gstreamer, maybe with phonon? but I'm getting lost with all the libraries and with the best way to make it also multiplatform

    Maybe I could try to launch gstreamer to record and stream the webcam, later with a "VideoPlayer" form phonon show the stream of both the local and the remote webcam... is this possible?

    Do you know any example on how to use gstreamer?

    I'm developing with QtCreator under linux, but it also has to work in windows...

    Thanks!

  2. #2
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Best way to stream and record a webcam

    Ok, so I made some progress although I don't know if it's in the good direction

    First of all, I have tested gstreamer alone, with gst-launch, and it works great to capture, record and stream the webcam both on linux and windows. If anyone is interested this is the command I use for the server part in linux (it also works in windows with some changes):

    Qt Code:
    1. gst-launch v4l2src device=/dev/video0 ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! tee name=t_vid ! queue ! videorate ! video/x-raw-yuv,framerate=30/1 ! theoraenc ! queue ! oggmux ! filesink location=test.ogg t_vid. ! queue ! xvimagesink sync=false t_vid. ! queue ! ffmpegcolorspace ! smokeenc keyframe=8 qmax=40 ! udpsink host=192.168.2.70 port=5000
    To copy to clipboard, switch view to plain text mode 

    I also have been able to play a video recorded with the command above with this code:

    Qt Code:
    1. QCoreApplication::setApplicationName("PhononTest");
    2. Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    3. Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this);
    4. Phonon::createPath(mediaObject, videoWidget);
    5.  
    6. QString url("./test.ogg");
    7. mediaObject->setCurrentSource(url);
    8. mediaObject->play();
    To copy to clipboard, switch view to plain text mode 

    But I still don't know how to show the live stream in the VideoWidget, I think setCurrentSource doesn't support that, but I'm not sure...

    It also would be great to be able to know how to launch gstreamer from my program, but I think first I have to be able to show the stream... any ideas?

    Is it possible with phonon or do I have to make it with plain gstreamer libraries? any examples?

    Thanks!

  3. #3
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Best way to stream and record a webcam

    Well, this is starting to become a monologue, maybe due to my impatience...

    But, in case anyone is interested I'm starting to get it working thanks to QtGStreamer which can be obtained from http://gitorious.org/qtgstreamer (more info in http://gkiagia.wordpress.com/) and makes it easy to work with GStreamer :-)

    I still have to test if QtGst will compile under windows, but in linux all works well :-)

    So many thanks to the QtGStreamer developers for making it so easy that a newbie can get it working in one day!

  4. #4
    Join Date
    Jun 2014
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Best way to stream and record a webcam

    hi,

    can you help me how you are streaming webcam using qt-gstreamer.
    I am using Qt-4.8.5.
    I am using linux.

  5. #5

    Default Re: Best way to stream and record a webcam

    this worked for me

    void gst_setup()
    {

    gst_init (NULL,NULL);

    bin = gst_pipeline_new ("pipeline");
    g_assert( bin);



    testSrc = gst_element_factory_make("v4l2src", "source");
    g_assert(testSrc);



    ffmpegcs = gst_element_factory_make ( "ffmpegcolorspace", "ffmpegcs" );


    encoder = gst_element_factory_make ( "jpegenc", "encoder" );
    g_assert(encoder);





    tcp = gst_element_factory_make ("tcpserversink", "tcp");
    g_assert(tcp);


    muxer = gst_element_factory_make ( "multipartmux", "muxer");


    g_object_set(tcp , "host", "192.168.5.77", NULL );
    g_object_set(tcp , "port", 5000 , NULL );
    g_object_set (testSrc, "capture-mode", 3 , NULL);


    videoOut = gst_element_factory_make("autovideosink", "video out");
    g_assert(videoOut);




    gst_bin_add_many(GST_BIN( bin), testSrc, ffmpegcs, encoder, muxer , tcp , NULL);


    gst_element_link_many( testSrc, ffmpegcs ,encoder, muxer, tcp, NULL);
    }
    if you have any questions let me know
    my Email : obalouchi1@gmail.com

Similar Threads

  1. Replies: 3
    Last Post: 26th March 2010, 04:32
  2. Control WebCam with Qt
    By lixo1 in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2009, 09:21
  3. Webcam USB under Windows with qt4
    By Wickinger in forum General Programming
    Replies: 3
    Last Post: 18th March 2008, 00:10
  4. Looking for a specific webcam...
    By hickscorp in forum General Discussion
    Replies: 0
    Last Post: 24th January 2008, 16:07
  5. use Webcam
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 21st August 2007, 07:52

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.