Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exportImage #417

Closed
ghost opened this issue Nov 14, 2019 · 3 comments · Fixed by #474
Closed

add exportImage #417

ghost opened this issue Nov 14, 2019 · 3 comments · Fixed by #474
Milestone

Comments

@ghost
Copy link

ghost commented Nov 14, 2019

Is there a way to programmatically get a frame of the recorded video data to send to a server & use as a thumbnail? I apologize if this question has been answered elsewhere. It looks like videojs or videojs-record does this for you to set the thumbnail of the video in the browser once you've finished recording. But I couldn't tell how from looking at the source

@thijstriemstra
Copy link
Member

@kylemadkins you can take a snapshot of the video element at any time, e.g.

// create new canvas
var canvas = document.createElement('canvas');
canvas.width = 320;
canvas.height = 240;
document.getElementsByTagName('body')[0].appendChild(canvas);

// draw video frame
var context = canvas.getContext('2d');
context.drawImage(player.record().mediaElement, 0, 0, canvas.width, canvas.height);

// download image
canvas.toBlob(function(blob){
    console.log(blob);
    // send to server here..
  },'image/png');

videojs-wavesurfer (used for audio-only in videojs-record) has an exportImage method to save image of the waveform, guess that would be useful in videojs-record as well to grab a frame of the video instead.

@thijstriemstra thijstriemstra changed the title [Question] Video Thumbnail add exportImage Nov 24, 2019
@ghost
Copy link
Author

ghost commented Nov 25, 2019

Thank you so much! I didn't know that mediaElement existed. And yeah I think that would be useful. Is there any way I could help out with that?

@thijstriemstra
Copy link
Member

@kylemadkins add an exportImage method in videojs.record.js and use a switch statement to handle the various cases (audio-only, video-only, audio-video) etc. Then open a pull request we can review.

@thijstriemstra thijstriemstra mentioned this issue May 18, 2020
@thijstriemstra thijstriemstra added this to the 4.0 milestone May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant