how to encode to jpeg plz help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to encode to jpeg plz help

sfaizanh
hi i have just found out a bug in my program, when i was coding on my pc i got different camera, now when i switched my application to laptop it dosent run because of camera

here is my code and gst command line:

Command Line:
gst-launch v4l2src ! image/jpeg,width=320,height=240,framerate=\(fraction\)20/1 ! ffmpegcolorspace ! tee name=t ! udpsink host=127.0.0.1 port=5000 t. ! queue ! jpegdec ! xvimagesink

C code

        GstCaps *caps;
        // Outgoing Pipelines
        videoPipeline = gst_pipeline_new("videoPipeline");
        audioPipeline = gst_pipeline_new("audioPipeline");
        /* create video elements */

        src = gst_element_factory_make("v4l2src", "video-src");
        splitter = gst_element_factory_make("tee", "video-splitter");
        sink = gst_element_factory_make("xvimagesink", "video-localsink");
        videoStream = gst_element_factory_make("udpsink", "video-transmitter");
        queue1 = gst_element_factory_make("queue","queue1");
        queue2 = gst_element_factory_make("queue","queue2");

        videoDec = gst_element_factory_make("jpegdec", "decoder");
        videoFilter = gst_element_factory_make ("ffmpegcolorspace", "filter");

        if (!videoPipeline)
        {
                printf("GStreamer Error: Could not create pipeline\n");
        }

        if(!src || !videoStream || !sink || !videoDec || !videoFilter)
        {

                printf("GStreamer Error: Video Elements: Could not create element\n");
        }

        if (!splitter)
        {

                printf("GStreamer Error: Splitter Element: Could not create video splitter\n");
        }

        if (!videoStream)
        {
                printf("Stream Creation failure.\n");
        }

        g_object_set(G_OBJECT(src),"device","/dev/video0",NULL);

        caps = gst_caps_new_simple ("image/jpeg",
                        "width", G_TYPE_INT, 320,
                        "height", G_TYPE_INT, 240,
                        "framerate",GST_TYPE_FRACTION,100,1,
                        NULL);

        // UDP Connection
        g_object_set(G_OBJECT(videoStream),"host",ipaddr, "port", outputPort, NULL);

        gst_bin_add_many(GST_BIN(videoPipeline),src, splitter, sink, videoDec, videoFilter, videoStream, queue1, queue2, NULL);

        if(!gst_element_link_many(src, splitter, NULL))
        {
                printf("Source -> Splitter Link failure\n");
        }


        pad1 = gst_element_get_request_pad(splitter, "src%d");  
        pad2 = gst_element_get_request_pad(splitter, "src%d");

        gst_element_link(splitter, queue1);
        gst_element_link(splitter, queue2);

        if(!gst_element_link_filtered (queue1, videoStream, caps)) {
                printf("Link between queue and stream failed.\n");
        }

        if (!gst_element_link_many(queue2, videoDec, videoFilter, sink, NULL))
        {
                printf("queue -> Local Src link failed\n");
        }


now i want to encode it to jpep because my camera dosent support image/jpeg but it supports video/x-raw-yuv, so i figured out the command line

gst-launch v4l2src ! video/x-raw-yuv,width=320,height=240,framerate=\(fraction\)5/1 ! ffmpegcolorspace ! jpegenc ! tee name=t ! udpsink host=127.0.0.1 port=5000 t. ! queue ! jpegdec ! xvimagesink

now can any body explain me how to enccode it :S
im stuck in code :S

                                                         -queue -> updsink
Source -> encode.to.jpeg -> filter -> tee
                                                         -queue -> decode.jpeg > xvimagesink
Reply | Threaded
Open this post in threaded view
|

Re: how to encode to jpeg plz help

Sudarshan Bisht
Instead of first encoding yuv to jpeg and again decoding back it to yuv, its better to encode it just before pushing to udpsink. And this would maintain your final goal also.
 
                                    -queue  -- > jpecgenc->udpsink
src ---> caps filter -> tee
                                   -queue --- > ffmpegcolorspace ! xvimagesink
 
 gst-launch v4l2src ! 'video/x-raw-yuv,width=320,height=240,format=(fourcc)I420,framerate=(fraction)20/1' ! tee name=t  ! queue  ! jpegenc !  udpsink host=127.0.0.1 port=5000   t. ! queue ! ffmpegcolorspace ! xvimagesink

 
On Wed, Dec 22, 2010 at 4:27 AM, sfaizanh <[hidden email]> wrote:

hi i have just found out a bug in my program, when i was coding on my pc i
got different camera, now when i switched my application to laptop it dosent
run because of camera

here is my code and gst command line:

Command Line:
gst-launch v4l2src !
image/jpeg,width=320,height=240,framerate=\(fraction\)20/1 !
ffmpegcolorspace ! tee name=t ! udpsink host=127.0.0.1 port=5000 t. ! queue
! jpegdec ! xvimagesink

C code

       GstCaps *caps;
       // Outgoing Pipelines
       videoPipeline = gst_pipeline_new("videoPipeline");
       audioPipeline = gst_pipeline_new("audioPipeline");
       /* create video elements */

       src = gst_element_factory_make("v4l2src", "video-src");
       splitter = gst_element_factory_make("tee", "video-splitter");
       sink = gst_element_factory_make("xvimagesink", "video-localsink");
       videoStream = gst_element_factory_make("udpsink", "video-transmitter");
       queue1 = gst_element_factory_make("queue","queue1");
       queue2 = gst_element_factory_make("queue","queue2");

       videoDec = gst_element_factory_make("jpegdec", "decoder");
       videoFilter = gst_element_factory_make ("ffmpegcolorspace", "filter");

       if (!videoPipeline)
       {
               printf("GStreamer Error: Could not create pipeline\n");
       }

       if(!src || !videoStream || !sink || !videoDec || !videoFilter)
       {

               printf("GStreamer Error: Video Elements: Could not create element\n");
       }

       if (!splitter)
       {

               printf("GStreamer Error: Splitter Element: Could not create video
splitter\n");
       }

       if (!videoStream)
       {
               printf("Stream Creation failure.\n");
       }

       g_object_set(G_OBJECT(src),"device","/dev/video0",NULL);

       caps = gst_caps_new_simple ("image/jpeg",
                       "width", G_TYPE_INT, 320,
                       "height", G_TYPE_INT, 240,
                       "framerate",GST_TYPE_FRACTION,100,1,
                       NULL);

       // UDP Connection
       g_object_set(G_OBJECT(videoStream),"host",ipaddr, "port", outputPort,
NULL);

       gst_bin_add_many(GST_BIN(videoPipeline),src, splitter, sink, videoDec,
videoFilter, videoStream, queue1, queue2, NULL);

       if(!gst_element_link_many(src, splitter, NULL))
       {
               printf("Source -> Splitter Link failure\n");
       }


       pad1 = gst_element_get_request_pad(splitter, "src%d");
       pad2 = gst_element_get_request_pad(splitter, "src%d");

       gst_element_link(splitter, queue1);
       gst_element_link(splitter, queue2);

       if(!gst_element_link_filtered (queue1, videoStream, caps)) {
               printf("Link between queue and stream failed.\n");
       }

       if (!gst_element_link_many(queue2, videoDec, videoFilter, sink, NULL))
       {
               printf("queue -> Local Src link failed\n");
       }


now i want to encode it to jpep because my camera dosent support image/jpeg
but it supports video/x-raw-yuv, so i figured out the command line

gst-launch v4l2src !
video/x-raw-yuv,width=320,height=240,framerate=\(fraction\)5/1 !
ffmpegcolorspace ! jpegenc ! tee name=t ! udpsink host=127.0.0.1 port=5000
t. ! queue ! jpegdec ! xvimagesink

now can any body explain me how to enccode it :S
im stuck in code :S

                                                        -queue -> updsink
Source -> encode.to.jpeg -> filter -> tee
                                                        -queue ->
decode.jpeg > xvimagesink

--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/how-to-encode-to-jpeg-plz-help-tp3159848p3159848.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel