使用 MATLAB 同时播放多个视频
我搜索了互联网和堆栈溢出,但找不到解决方案,甚至找不到对我的问题有帮助的提示。
我需要在 MATLAB 中编写一个专门的视频注释软件,该软件必须能够在 GUI 上同时播放多个视频(至少 2 个)。视频文件采用 XVID 编码。到目前为止,我基本上只是调整了 mathworks.com 的视频播放示例(xylophon.avi,请参阅 movie() 描述)。
我熟悉 mmreader、VideoReader、movie 和 implay 功能,但仍然面临两个问题:
即使我只读取少量帧(如 xylophon.avi 示例),我的程序很快就会超出可用范围记忆。而且,即使读取相对较少的帧(比如 100),也需要相当长的时间。
movie() 函数是同步的,因此在第一个视频完成之前第二个视频不会开始。如何同时调用两个 movie() 函数?或者是否有另一种方法可以同时显示两个(或更多)视频?
有什么建议吗?谢谢!
I searched the internet and stack overflow but could not find a solution or even helpful hints to my problem.
I need to write a specialised video annotation software in MATLAB which has to be capable to play multiple videos (at least 2) simultaneously on a GUI. The video files are XVID-encoded. Up to now, I basically just adjusted the mathworks.com example for video playback (xylophon.avi, see movie() description).
I am familiar with the mmreader, VideoReader, movie and implay functions but still I am facing two issues:
Even if I read in only a small number of frames (like in the xylophon.avi example), my progam soon exceeds available memory. Also, it takes quite long to read in even relatively few frames (say 100).
The movie() function is sycnhronous, so the second video does not start until the first video completed. How can I call two movie()-functions concurrently? Or is there another way to show two (or more) videos simultaneously?
Any suggestions? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,MATLAB 不是多线程的。并行做两件事会很困难。尝试突破到Java。 Matlab 使用 JIDE 作为基于 Swing 构建的图形前端。使用 MATLAB Builder JA 将 MATLAB 代码编译为 Java,或添加将您自己的“面板”添加到 IDE,如 这个问题。
First of all MATLAB is not multithreaded. Doing two things in parallel will be difficult. Try to breakout to Java. Matlab uses JIDE as their graphical front-end which is built on Swing. Use MATLAB Builder JA in order to compile your MATLAB code to Java, or add your own 'Panels' to the IDE as shown in this question.
您可以在两个不同的窗口中显示视频,并通过为视频提供句柄并调用其未记录的播放函数来同时开始播放。这也消除了您在处理长度不等的视频时可能遇到的任何困难。
You could display the videos in two different windows and start the playback simultaneously by giving the videos a handle and calling its undocumented play function. This removes any struggle you might have with videos of unequal length as well.
原则上,您可以将每个视频帧显示为图像并交替更新每个视频,但使其以完全正确的帧速率播放可能很困难。
尝试如下操作。这可能无法按原样工作,但您应该能够更新它。
In principle, you can display each video frame as an image and alternate updating each video, but getting it to play at exactly the right frame rate might be difficult.
Try something like the following. This probably won't work as-is, but you should be able to update it.