8

I'm getting an mjpeg stream via http and viewing it using the <img> tag. Pretty standard and no problem there, everything is streaming correctly.

However, along with the encoded jpg data there's a UTC timestamp in the http response that I'd like to access. Basically, I'd like to be able to display the matching time with each frame. Here's the response I'm working with for each frame that comes through:

Content-Type: image/jpeg
Content-Length: 60189
Time-Stamp: 51961243969
UTC-Time: 1349439599864
Flags: 2097153
PlayID: 1
Camera-Type: Halocam IP
Connection: Close

[encoded jpg data]
--myboundary

Currently the <img> tag is taking that stream and interpreting the jpgs directly. Is there anyway to intercept, interpret or separate the UTC-Time value via javascript so I could display it on the page? I don't control the http response, but if a solution were available via some change there, I could talk to the person who does control it.

EMH
  • 81
  • 4

2 Answers2

0

use XMLHttpRequest, then extract all of its response headers

Tyler
  • 183
  • 9
  • Is there an example where XMLHttpRequest is used to fetch an mjpeg stream? I am working on creating a module to fetch the stream from a path through XMLHttpRequest and then extracting the data out of it. – Himanshu Singla Jul 26 '17 at 15:13
0

example with jquery:

$.ajax({url:'a.jpg', 
        complete: function(r){
              console.log(r.getAllResponseHeaders());
        }
})
konghou
  • 557
  • 7
  • 20