在视频画布上插入文本,并以MP4导出
假设您有一个带有MP4视频源的HTML5 <
元素:
#video { width: 400px; }
#text { font-size: 30px; background-color: yellow; }
<video controls id="video"><source src="https://samplelib.com/lib/preview/mp4/sample-5s.mp4">
<span id="text">Hello world</span>
</video><br>
<button>Export</button>
&lt; span&gt;
在这里是看不见的,是否可以在视频帆布的顶部看到它,因此我们可以将视频 +文本导出为新的mp4(渲染)(渲染)视频?
我可以想象,如今,某些浏览器API中包含在不需要外部库的情况下,是否正确?
Let's say you have a HTML5 <video>
element with an MP4 video source:
#video { width: 400px; }
#text { font-size: 30px; background-color: yellow; }
<video controls id="video"><source src="https://samplelib.com/lib/preview/mp4/sample-5s.mp4">
<span id="text">Hello world</span>
</video><br>
<button>Export</button>
The <span>
here is invisible, is there a way to make it visible on top of the video canvas, such that we can export the video + text as a new MP4 (rendered) video?
I can imagine this is nowadays included in some browser API, without the need of an external library, is it correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的答案...不容易。
您可以将视频推到画布上,覆盖文本,然后使用 https://github.com/ Antimatter15/whammy 将画布保存为视频,但沿途将会有相应的保真度损失。
最好是使用在使用php ),然后将输出介绍给用户后的输出后
short answer ... not easily.
You can push the video to a canvas, overlay the text, and then use something like https://github.com/antimatter15/whammy to save the canvas as a video but there will be a corresponding loss of fidelity along the way.
Far better would be to use something like ffmpeg server side as in this example and trigger it from your web page (eg using PHP) and then present the output once completed to the user