Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:11:54+00:00 2026-05-25T13:11:54+00:00

I have created a mjpeg stream. I have embedded content length in between the

  • 0

I have created a mjpeg stream. I have embedded content length in between the two jpeg frames [between footer of first frame and header of the next frame].

[MJPEG STREAM]
      |
      V
...
----------
JPEG FRAME
(Image)
----------
Content-length
(Text)
----------
JPEG FRAME
(Image)
----------
Content-length
(Text)
----------
JPEG FRAME
(Image)
----------
...
      |
      V

I am able to play the video using gstreamer-java, gstreamer C API and gst-launch. However I am trying to parse the content-length text in gstreamer-java. I tried “meta tags” but that doesn’t yield any result I need

I play mjpeg stream that I created as follows

gst-launch -v souphttpsrc location="<ip>:<port>/<cgi_bin folder>/<name>.cgi" do-timestamp=true is_live=true ! multipartdemux ! jpegdec ! ffmpegcolorspace ! autovideosink

I tried meta tags using

gst-launch -v souphttpsrc location="<ip>:<port>/<cgi_bin folder>/<name>.cgi" do-timestamp=true is_live=true ! multipartdemux ! jpegdec ! fakesink -t

and this

gst-launch -v souphttpsrc location="<ip>:<port>/<cgi_bin folder>/<name>.cgi" do-timestamp=true is_live=true ! fakesink -t

However the output of this media pipeline is something like the following

/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = "chain   ******* < (557568   
bytes, timestamp: 0:00:06.895505695, duration: none, offset: -1, offset_end: -1, flags: 
0) 0x9a82818"
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = "chain   ******* < (557568 
bytes, timestamp: 0:00:06.941328354, duration: none, offset: -1, offset_end: -1, flags: 
0) 0x9a6f6e0"

As it can be seen no content-length. 🙁 . I use WireShark and see data packets containing content-length. Subsequently I wrote a separate Java Code (with no gstreamer plugins) and I can parse the stream to get the content length. However this is not the ideal method as I want the content-length corresponding to the exact frame keeping in view the synchronization.

I have written tees before for C API code. I am wondering if tee would work in this instance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:11:55+00:00Added an answer on May 25, 2026 at 1:11 pm

    Appsink came in handy. The pipeline looks like

                             _ queue -> appsink -> parser 
                           /  
            video -> tee ->
                           \_ demux -> decoder -> ffmpegcolorspace -> autovideosink 
    

    The Java Code snippet looks like

    First define the appsink bin

    final AppSink appsink = (AppSink) ElementFactory.make("appsink", "appsink");
    

    Then its properties …

    appsink.set("emit-signals",true);
    appsink.set("max-buffers",1);
    //appsink.set("drop",true); //Make this non-blocking. 
                                //Meaning drop frames when queue is full
    

    Then its function …

    appsink.connect(new AppSink.NEW_BUFFER() {
    @Override public void newBuffer(Element elem, Pointer userData) {
    AppSink appsink = (AppSink) elem;
    Buffer buffer = appsink.pullBuffer();  //get the stream data as an input to external 
                                           //applications
    
    /*
    // Create a character ByteBuffer
    CharBuffer cbuf = byteBuffer.asCharBuffer();
    */
    
    ByteBuffer byteBuffer = buffer.getByteBuffer();
    byte[] bytearray = new byte[byteBuffer.remaining()];
    byteBuffer.get(bytearray);
    String s = new String(bytearray);
    //InputStream is = new ByteArrayInputStream(bytearray);
    // System.out.print(buffer.getSize()+"\n");
    //  System.out.print(s+"\n");
    
    //Do whatever with this buffer inside string here e.g. parsing text content
    
    ...
    
    byteBuffer.clear();
    buffer.dispose();
    buffer = null;
    
    }
    });           
    

    //===========================================================================

    The C code snippet looks like

    ...
    sink = gst_element_factory_make ("appsink", "Output");
    g_assert (sink);
    

    Then…

    ...
    gst_app_sink_set_max_buffers((GstAppSink*)sink, 100);
    gst_app_sink_set_emit_signals ((GstAppSink*)sink, TRUE);
    g_signal_connect (sink, "new-buffer",  G_CALLBACK(new_buffer), NULL);
    

    Then…

    static GstFlowReturn new_buffer (GstAppSink *app_sink, gpointer user_data)
    {
      char* pipe_name = (char*) user_data;
      GstBuffer* buffer = gst_app_sink_pull_buffer(app_sink);
    
    //  g_debug("appsink buffer timestamp(%lli) size(%d)",
    //          GST_BUFFER_TIMESTAMP(buffer),
    //          GST_BUFFER_SIZE(buffer));
    
      g_print((char*)buffer);
    
      gst_buffer_unref(buffer);
      return GST_FLOW_OK;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a few small flash widgets that stream .mp3 audio from an
I am developing an application that sends a stream of JPEG images (MJPEG stream)
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a C# class file by using a XSD-file as an input.
i have created a workflow activity that do give the item creater of a
I have created a foreign key (in SQL Server) by: alter table company add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.