【发布时间】:2015-01-05 15:52:22
【问题描述】:
我正在构建一个跨平台应用程序来记录多媒体文件以进行持续处理。这是基于继承的应用程序,我无法使用替代库重写。
我当前的问题是 QMediaRecorder 显然没有将视频文件保存到本地驱动器上 - 我暂时将要保存为 banana.mov 的文件硬编码到用户根文件夹中。
执行时,输出文件不会被保存。
我尝试按照here 的建议强制解决问题,并且看到其他人在从 Windows 录制时遇到问题,但 OSX 是fine
使用 Qt5.4 的开发环境 OSX 10.10(同样的问题也发生在使用 Qt5.3 的 Windows 8.1 机器上)
此code on 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.'
我有一种感觉,我错过了一些非常明显的东西,我只是还没有发现它!
edit 1 很明显,状态是Recording is requested but not active yet 而不是Recording is active。我目前正在尝试找出为什么录制没有开始。
edit 2 录音机示例确实记录并保存了一个音频文件。看起来 QMediaRecorder 不返回可用音频编解码器列表,但 QAudioRecorder 确实返回音频编解码器列表。我在使用 Qt5.3 的 Windows 8.1 和使用 Qt 5.4 的 OSX 上都得到了相同的结果
【问题讨论】:
-
只是一个快速测试,而不是使用“~/blah”,你可以尝试指定完整路径,看看会发生什么例如:“/home/neil/blah.mov " 或 "c:\users\neil\blah.mov" 我不知道这是否重要,但在我的脑后,有一些与 QT 无关的东西在回响。
-
这已经在示例代码中完成了技巧:pint owed。如果您提出作为答案,我会这样标记它。