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

  • Home
  • SEARCH
  • 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 6043101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:51:45+00:00 2026-05-23T06:51:45+00:00

I create a little application with nodejs that stream a multipart/x-mixed-replace data to browser.

  • 0

I create a little application with nodejs that stream a multipart/x-mixed-replace data to browser.

This data is created with image data, but the image data may change over time, so in the browser it looks like a video. The image data is created from a webcam, so in the browser it looks like live streaming.

But the performance isn’t very good.

I’ve tried some other approaches:
– First: Use socket.io to push images to browser, here i use the base64 data from the image (push this data) and in the browser i recreate the image (jpeg): works good, but only with one or two clients.
_ Second: Use polling from browser to nodejs server.. this doesn’t like me.

So this is the code: (some part of the code of my nodejs server) I use express to make the http server:

app.get('/videoStream',function(req,response){   
    response.writeHead(200,{
        'Content-Type': 'multipart/x-mixed-replace;boundary="' + boundary + '"',
        'Connection': 'keep-alive',
        'Expires': 'Fri, 01 Jan 1990 00:00:00 GMT',
        'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
        'Pragma': 'no-cache'
    });
    response.write('--'+boundary+'\n');

    events.addListener('imagen_recibida',function(){
        fs.readFile(__dirname + '/image.jpeg',function(err,data){
             if(err) return send404(response);
             response.write('Content-Type: image/jpeg\n Content-Length: '+data.length+'\n\n');
             response.write(data);
            response.write('\n--'+boundary+'\n');
           });
    });

When the event “imagen_recibida” rise, it reads the image from disk and write the data to browser.

So the two questions:

Is there any approach to improve the performance of this? (write the image to disk and then read to send to browser doesn’t see like a good trick)

Is there a method to encode this into another format to improve performance?

Thanks a lot.

PD: The image is written to disk and then read to send to browser, because I receive the image data from another process in another function via RPC calls.

  • 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-23T06:51:46+00:00Added an answer on May 23, 2026 at 6:51 am

    You could trying using socket.io to just push URLs of the generated files and then on the client use Javascript to replace the “src” attribute of the img tag showing the frame. In this case you could use a regular web server for server the static files or the connect module for serving static files. This is likely more efficient than pushing the base64 encoded data.

    If you are going to use the approach above, at least don’t use fs.readFile… this brings the whole file into memory every time. Use util.pump() or manually use ReadStream/WriteStream with ‘drain’ events to minimize memory usage. Its possible that your performance issues are due to garbage collection when there are multiple clients connected.

    Another approach might be to have a background process that feeds the images to ffmpeg to encode a proper video stream and then to ffserver to stream it to a video player.

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

Sidebar

Related Questions

No related questions found

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.