Jump to content
  • 0

Capture Stream Image frequently


Цэрэнчимэд Цэгмид
 Share

Question

  • Answers 6
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

6 answers to this question

Recommended Posts

  • 0

Hi

I tried to get the image from the client, grab from the stream then upload to server
 but for some reason i cant get it to work.
where did you find this config to make a preview ?

here is the code :
 var firstVideoTrack;
 navigator.mediaDevices.getUserMedia({ video: true })
 .then(mediaStream => {
 firstVideoTrack = mediaStream.getVideoTracks()[0];
 });

 var imageinterval;
 var imageCapture;
 var photo;

 function captureimage(){
 imageCapture = new ImageCapture(firstVideoTrack);
 imageCapture.takePhoto().then(function(blob) {
 photo = URL.createObjectURL(blob);
 document.getElementById('capture').src=photo;
 var formData = new FormData();
 formData.append(
 "FILES[]", photo
 );

 $.ajax({
 url: "upload_camimages.php",
 type: "POST",
 enctype: 'multipart/form-data',
 processData: false, // Important!
 contentType: false,
 cache: false,
 data: formData,
 })
 }
 )
 }

thanks

 

Link to comment
Share on other sites

  • 0

Hi,

Thank you for your contribution to the community.

I am sorry to say this but 2.2.1 version is problematic with the previews, I don't recommend to use previews in that version ( https://github.com/ant-media/Ant-Media-Server/issues/2801 )

You can indeed capture the stream from client side in the javascript, you can draw the stream on top a canvas and get the image from toDataUrl method if client side capturing is good enough for you.

Thanks

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...