-
Notifications
You must be signed in to change notification settings - Fork 562
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
fix: use frames for video capture & add iframes #346
Conversation
💖 Thanks for opening this pull request! 💖 Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
👋 @DustinBrett Congrats on merging your first pull request! 🎉🎉🎉 |
🎉 This PR is included in version 1.11.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
iframe css not working |
Yes it does have some limitations currently I'd noticed. Same with images. I think it needs it's base url to be from the iframe. If you have a suggestion where to tweak it please PR. |
#351
|
I see the problem now from your solution. I have a fix in general I'm also interested in possibly PR'ing. I think |
## [1.11.2](bubkoo/html-to-image@v1.11.1...v1.11.2) (2022-12-13) ### Bug Fixes * fallback to `poster` when `currentSrc` of video is null ([5d79666](bubkoo@5d79666)) * use frames for video capture & add iframes ([bubkoo#346](bubkoo#346)) ([e316c61](bubkoo@e316c61))
## [1.11.2](bubkoo/html-to-image@v1.11.1...v1.11.2) (2022-12-13) ### Bug Fixes * fallback to `poster` when `currentSrc` of video is null ([5d79666](bubkoo@5d79666)) * use frames for video capture & add iframes ([bubkoo#346](bubkoo#346)) ([e316c61](bubkoo@e316c61))
## [1.11.2](bubkoo/html-to-image@v1.11.1...v1.11.2) (2022-12-13) ### Bug Fixes * fallback to `poster` when `currentSrc` of video is null ([5d79666](bubkoo@5d79666)) * use frames for video capture & add iframes ([bubkoo#346](bubkoo#346)) ([e316c61](bubkoo@e316c61))
## [1.11.2](bubkoo/html-to-image@v1.11.1...v1.11.2) (2022-12-13) ### Bug Fixes * fallback to `poster` when `currentSrc` of video is null ([5d79666](bubkoo@5d79666)) * use frames for video capture & add iframes ([bubkoo#346](bubkoo#346)) ([e316c61](bubkoo@e316c61))
## [1.11.2](bubkoo/html-to-image@v1.11.1...v1.11.2) (2022-12-13) ### Bug Fixes * fallback to `poster` when `currentSrc` of video is null ([5d79666](bubkoo@5d79666)) * use frames for video capture & add iframes ([bubkoo#346](bubkoo#346)) ([e316c61](bubkoo@e316c61))
This pull request addresses the issue with capturing videos and iframes in the library, where the resulting images were blank or incorrect.
Description
To fix this issue, I have updated the
cloneVideoElement
andcloneIframeElement
functions to use thecontentDocument.body
andcanvas
APIs to capture frames from the videos and iframes, and convert them to data URLs.For videos, I have added a
canvas
element to the page, set its size to the same size as the video, and used thedrawImage
method to draw the video to the canvas. I have then used thecanvas.toDataURL
method to convert the canvas image to a data URL.For iframes, I have used the
contentDocument
property of theHTMLIFrameElement
to access thedocument
object of the iframe, and then used thequerySelector
method to find the video element of the iframe. I have then used the same approach as before to capture a frame from the video and convert it to a data URL.I have also added error handling to the functions to catch any errors that may be thrown by these APIs, and added tests to verify that the fixes work as expected.
Please review and let me know if there are any changes needed. Thank you!
ChatGPT helped me
Motivation and Context
This is related to these issues
Video capture
#312
#202
#193
iFrame capture
#192
#167
#36
Types of changes
Self Check before Merge