仅播放视频而不播放声音。这是为什么 ?

发布于 2024-11-27 02:49:25 字数 264 浏览 5 评论 0 原文

我读了这段代码使用xuggler作为库播放视频文件。当我运行此代码时,播放没有声音的视频。这是为什么?

如果不是,我应该怎么做才能播放音频和视频?

I read this code to play video files using xuggler as a library.When i run this code , the video without sound plays.Why is that ?

If not what should i do to play audio with video.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝眼睛不忧郁 2024-12-04 02:49:25

很简单,这是因为该代码不播放任何音频。从来没有写过这样做!

如果您想播放音频和视频,请查看此处的示例:

http://xuggle.googlecode.com/svn/trunk/java/xuggle-xuggler/src/com/xuggle/xuggler/demos/DecodeAndPlayAudioAndVideo.java

对我来说的问题表明您我只是在没有查看教程的情况下获取了源代码 - 我强烈建议这样做,这样您就可以理解正在发生的事情背后的代码,而不是仅仅将其扔在那里并期望它能够工作 - 特别是如果您打算深入使用 Xuggler!

进一步说明,如果您只想播放视频,我可能不建议使用 Xuggler,因为它并不是真正为此类事情而设计的。当然它会播放它们,但你必须自己管理所有同步问题(上面的示例并没有很好地解决),它只会使用你的 CPU,因此会真正消耗它的消耗,特别是如果你正在这样做像高清视频这样的东西,大量的后台代码简直是多余的(获取流、查找流 ID、提取每个数据包、确定数据包的类型、适当处理它、管理错误等等)。一个很棒的软件,但是如果如果你只是用它来玩东西,那么它给你带来的麻烦可能远远超过它的价值。

相反,我建议尝试使用 VLCJ - 设置它以可靠地工作有点复杂(需要进程外播放器才能保持坚如磐石的稳定性),但当你做到这一点时,它可以在几乎任何文件类型下播放sun 可以为您解决上述所有问题,这比您手动处理的要好得多!

Quite simply, it's because that code doesn't play any audio. It was never written to do so!

If you want to play audio and video, check out the example here:

http://xuggle.googlecode.com/svn/trunk/java/xuggle-xuggler/src/com/xuggle/xuggler/demos/DecodeAndPlayAudioAndVideo.java

The question to me suggests that you've just grabbed the source without looking at the tutorials - I'd strongly suggest doing so so you can understand the code behind what's going on rather than just throwing it in there and expecting it to work - especially if you're planning on using Xuggler in any great depth!

As a further note, if all you want to do is play videos I probably wouldn't advise using Xuggler because it's just not really designed for that sort of thing. Sure it will play them, but you have to manage all the sync issues yourself (which the above example doesn't do a great job of), it will only use your CPU and therefore really eat into its consumption especially if you're doing things like HD video, and the sheer amount of background code is just overkill (getting the streams, finding the stream IDs, extracting each packet, determining the type of the packet, dealing with it appropriately, managing errors, etc. etc.) It's a great piece of software, but if you're only using it to play stuff then it'll probably give you far more trouble than its worth.

Instead I'd advocate having a play with VLCJ - it's a bit complicated to get set up to work reliably (out of process players are required for rock solid stability) but when you've got that far it plays near any file type under the sun and manages all the issues above for you much, much better than you'll ever cope with by hand!

素手挽清风 2024-12-04 02:49:25

我的猜测是您缺少音频编解码器。我也遇到过同样的问题,但反之亦然;声音播放了,但视频没有播放。

My guess is that you have a missing audio codec. I've had this same issue but vice versa; the sound played but the video didn't.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文