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 993567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:26:39+00:00 2026-05-16T06:26:39+00:00

I want to write MJPEG picture internet stream viewer. I think getting jpeg images

  • 0

I want to write MJPEG picture internet stream viewer. I think getting jpeg images using sockets it’s not very hard problem. But i want to know how to make accurate streaming.

while (1)
{
     get_image()
     show_image()
     sleep (SOME_TIME) // how to make it accurate?
}  

Any suggestions would be great.

  • 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-16T06:26:39+00:00Added an answer on May 16, 2026 at 6:26 am

    In order to make it accurate, there are two possibilities:

    Using framerate from the streaming server. In this case, the client needs to keep the same framerate (calculate each time when you get frame, then show and sleep for a variable amount of time using feedback: if the calculated framerate is higher than on server -> sleep more; if lower -> sleep less; then, the framerate on the client side will drift around the original value from server). It can be received from server during the initialization of streaming connection (when you get picture size and other parameters) or it can be configured.

    The most accurate approach, actually, is using of timestamps from server per each frame (which is either taken from file by demuxer or generated in image sensor driver in case of camera device). If MJPEG is packeted into RTP stream, these timestamps are already in RTP header. So, client’s task is trivial: show picture using time calculating from time offset, current timestamp and time base.

    Update
    For the first solution:

    time_to_sleep = time_to_sleep_base = 1/framerate;
    number_of_frames = 0;
    time = current_time();
    while (1)
    {
         get_image();
         show_image(); 
         sleep (time_to_sleep);
    
         /* update time to sleep */
         number_of_frames++;
         cur_time = current_time();
         cur_framerate = number_of_frames/(cur_time - time); 
         if (cur_framerate > framerate)        
             time_to_sleep += alpha*time_to_sleep;
         else 
             time_to_sleep -= alpha*time_to_sleep;
         time = cur_time;
    } 
    

    , where alpha is a constant parameter of reactivity of the feedback (0.1..0.5) to play with.

    However, it’s better to organize queue for input images to make the process of showing smoother. The size of queue can be parametrized and could be somewhere around 1 sec time of showing, i.e. numerically equal to framerate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write <a href=product.php?id=5> as product/5.I am not talking about user to
I want to write a php application using Zend Framework 2 (just the beta
I am using spring 3.0 org.springframework.web.multipart.commons.CommonsMultipartFile for file uploading. i want write down unit
I want write a simple query which will fetch data from a table (which
I want write a little code analyzer which parses nested structures and translates into
Hello I want write my own desktop sharing application in Java. The application should
I want to write a batch script statement where: FINDSTR has to check for
I want to write a program in Prolog that confirms if a b-tree of
I want to write a procedure to perform a delete for the following i
I want to write a program to contact a PHP script online, and show

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.