尝试在 Phonon 中以不同速度播放音频时 availableAudioEffects() 错误

发布于 2024-11-17 15:51:24 字数 2399 浏览 7 评论 0原文

我正在尝试研究如何在 Ubuntu 中使用 Phonon 以不同的速度播放声音。我的第一个想法是检查函数调用中可用的选项:

 Phonon.BackendCapabilities.availableAudioEffects()

但是,当我导入 PyQt 和 Phonon 然后进行该函数调用时会发生以下情况:

 ely@zaffpants:~/Desktop$ python2.6
 Python 2.6.6 
 [GCC 4.5.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import PyQt4; from PyQt4.phonon import Phonon
 >>> print Phonon.BackendCapabilities
 <class 'PyQt4.phonon.BackendCapabilities'>
 >>> print Phonon.BackendCapabilities.availableAudioEffects()
 WARNING: Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface 
 ASSERT: "QCoreApplication::instance()" in file ../../phonon/factory.cpp, line 378
 Aborted
 ely@zaffpants:~/Desktop$ 

我在网上找不到任何好的线程。为什么这会中止?另请注意,在我当前的程序中,我已经使用 Phonon 同时播放多个音频流,甚至将其链接到管理自定义视频播放器(不在 Phonon 中)的 Qt 线程,以保持音频同步,即使用户在视频中拖动速度更快。因此,必须正确安装 Phonon 才能达到这种程度,而且我已经使用了一些后端功能。为什么当我查询有哪些后端效果时会中止?

有什么建议吗?即使他们没有修复这个错误,是否有任何关于如何强制 Phonon 比正常更快或更慢地播放音频文件的建议?

添加

我通过执行以下操作解决了中止问题:导入 PyQt 和 Phonon 后,我创建了一个虚拟 QApplication 并给了它一个名称,如下所示

>>> import sys
>>> app = PyQt4.QtGui.QApplication(sys.argv)
>>> app.setApplicationName('myname')
>>> print Phonon.BackendCapabilities.availableAudioEffects()

但这里是函数的输出,即使在指定之后列表中的一项不可读。不知道如何将其转化为可读的形式......?

(<unknown>:1848): GStreamer-CRITICAL **: gst_debug_add_log_function: assertion `func != NULL' failed
[<PyQt4.phonon.EffectDescription object at 0x7f941539ed70>,   <PyQt4.phonon.EffectDescription object at 0x7f941539ef30>, <PyQt4.phonon.EffectDescription   object at 0x7f941539efa0>, <PyQt4.phonon.EffectDescription object at 0x7f9408032050>, <PyQt4.phonon.EffectDescription object at 0x7f94080320c0>, <PyQt4.phonon.EffectDescription object at 0x7f9408032130>]
>>> print Phonon.BackendCapabilities.availableAudioEffects()[0]
<PyQt4.phonon.EffectDescription object at 0x7f941539ed70>

后脚本 正如在下面的评论中,我弄清楚了大部分与 Phonon 中的音频速度有关的内容,该线程在这里:< 有关 PyQt Phonon 后端音频效果“速度”的文档>

I'm trying to investigate how to play sound at different speeds with Phonon in Ubuntu. My first thought was to examine what options are available in the function call:

 Phonon.BackendCapabilities.availableAudioEffects()

However, here is what happens when I import PyQt and Phonon and then make that function call:

 ely@zaffpants:~/Desktop$ python2.6
 Python 2.6.6 
 [GCC 4.5.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import PyQt4; from PyQt4.phonon import Phonon
 >>> print Phonon.BackendCapabilities
 <class 'PyQt4.phonon.BackendCapabilities'>
 >>> print Phonon.BackendCapabilities.availableAudioEffects()
 WARNING: Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface 
 ASSERT: "QCoreApplication::instance()" in file ../../phonon/factory.cpp, line 378
 Aborted
 ely@zaffpants:~/Desktop$ 

I can't find any good threads on this online. Why is this aborting? Please also note that in my current program, I am already using Phonon to play multiple audio streams simultaneously and even have it linked to a Qt thread that manages a custom video player (not in Phonon) to keep the audio in sync even when a user drags faster through the video. So, Phonon must be installed correctly in order to work to this degree and I've been using some backend capabilities features already. Why the abort when I query what backend effects are there?

Any suggestions? And even if they don't fix this error, are there any suggestions for how to force Phonon to play an audio file faster or slower than normal?

Added

I solved the abort problem by doing the following: after importing PyQt and Phonon, I created a dummy QApplication and gave it a name, as follows

>>> import sys
>>> app = PyQt4.QtGui.QApplication(sys.argv)
>>> app.setApplicationName('myname')
>>> print Phonon.BackendCapabilities.availableAudioEffects()

But here is the output of the function, which even after specifying one item from the list, is not readable. Not sure how to put it into readable form...?

(<unknown>:1848): GStreamer-CRITICAL **: gst_debug_add_log_function: assertion `func != NULL' failed
[<PyQt4.phonon.EffectDescription object at 0x7f941539ed70>,   <PyQt4.phonon.EffectDescription object at 0x7f941539ef30>, <PyQt4.phonon.EffectDescription   object at 0x7f941539efa0>, <PyQt4.phonon.EffectDescription object at 0x7f9408032050>, <PyQt4.phonon.EffectDescription object at 0x7f94080320c0>, <PyQt4.phonon.EffectDescription object at 0x7f9408032130>]
>>> print Phonon.BackendCapabilities.availableAudioEffects()[0]
<PyQt4.phonon.EffectDescription object at 0x7f941539ed70>

Post Script
As in the comments below, I figured most of this out regarding the audio speed in Phonon, and that thread is here: < Documentation on PyQt Phonon backend audio effect 'speed' >

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

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

发布评论

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

评论(1

相思碎 2024-11-24 15:51:24

您将获得 EffectDescription 对象的列表。您可以从类参考获取API 。例如,

>>>for effect in Phonon.BackendCapabilities.availableAudioEffects():
       print effect.name()

ParamEq
WavesReverb
Gargle
Compressor
Distortion
Echo
I3DL2Reverb
Flanger
Chorus

另一方面,我认为您的安装有些问题。我不熟悉 Ubuntu,但我认为您不应该收到这些错误消息。我认为您也不应该创建 QApplication 对象来获取此信息。在 WinXP 上我不需要这么做。

You are getting a list of EffectDescription objects. You can get the api from the class reference. For example,

>>>for effect in Phonon.BackendCapabilities.availableAudioEffects():
       print effect.name()

ParamEq
WavesReverb
Gargle
Compressor
Distortion
Echo
I3DL2Reverb
Flanger
Chorus

On another note, I think something is borked with your installation. I'm not familiar with Ubuntu, but I don't think you should be getting those error messages. I don't think you should have to create a QApplication object to get this info either. I didn't have to on WinXP.

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