我正在构建一个跨平台应用程序来记录多媒体文件以进行持续处理。这是基于继承的应用程序,我无法使用替代库重写。
我当前的问题是QMediaRecorder显然没有将视频文件保存到本地驱动器上 - 我暂时将要保存的文件硬编码banana.mov
到用户根文件夹中。
执行时,不会保存输出文件。
我已尝试按照此处的建议强制解决,并且看到其他人在从 Windows 录制时遇到问题,但 OSX很好
使用 Qt5.4 的开发环境 OSX 10.10(同样的问题也发生在使用 Qt5.3 的 Windows 8.1 机器上)
Github上的此代码基于相机示例,在尝试识别和重现问题时添加了额外的调试代码。
在调查时,QMediaRecorder::supportedAudioCodecs和 QMediaRecorder::supportedVideoCodecs都返回空列表。这发生在 OSX 构建和 Windows 环境中。
调试输出如下:
Status change SIGNAL 'The recorder is initializing.'
Output location file:~/banana.mov
2015 01 05 14:59:58.111 Number of supported AUDIO Codecs 0
2015 01 05 14:59:58.111 Number of Audio sample rates 0
2015 01 05 14:59:58.111 Number of Video Codecs 0
2015 01 05 14:59:58.111 Number of Video Frame Rates 0
2015 01 05 14:59:58.111 Number of Containers 0
Location Changed SIGNAL 'file:~/banana.mov'
State change SIGNAL 'The recording is requested.'
Recording should have started
2015 01 05 14:59:58.111 Number of supported AUDIO Codecs 0
2015 01 05 14:59:58.111 Number of Audio sample rates 0
2015 01 05 14:59:58.111 Number of Video Codecs 0
2015 01 05 14:59:58.111 Number of Video Frame Rates 0
2015 01 05 14:59:58.111 Number of Containers 0
Status change SIGNAL 'Recording is requested but not active yet.'
我有一种感觉,我错过了一些非常明显的东西,我只是还没有发现它!
编辑 1很明显,状态是Recording is requested but not active yet
而不是Recording is active
。我目前正在尝试找出录制尚未开始的原因。
编辑 2录音机示例确实记录并保存了一个音频文件。看起来 QMediaRecorder没有返回可用音频编解码器的列表,但 QAudioRecorder确实返回了音频编解码器的列表。我在使用 Qt5.3 的 Windows 8.1 和使用 Qt 5.4 的 OSX 上都得到了相同的结果