mirror of
https://github.com/opencv/opencv.git
synced 2024-12-01 06:49:50 +08:00
f36c268b9e
add audio support in cap_msmf * audio msmf * fixed warnings * minor fix * fixed SampleTime MSMF * minor fix, fixed audio test, retrieveAudioFrame * fixed warnings * impelemented sync audio and video stream with start offset * fixed error * fixed docs * fixed audio sample * CAP_PROP_AUDIO_POS, minor fixed * fixed warnings * videoio(MSMF): update audio test checks, add debug logging * fixed * fixed desynchronization of time positions, warnings * fixed warnings * videoio(audio): tune tests checks * videoio(audio): update properties description * build warnings Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
// Usage: opencv_test_videoio --gtest_also_run_disabled_tests
|
|
|
|
#include "test_precomp.hpp"
|
|
|
|
namespace opencv_test { namespace {
|
|
|
|
TEST(DISABLED_videoio_micro, basic)
|
|
{
|
|
int cursize = 0;
|
|
int validSize = 0;
|
|
Mat frame;
|
|
|
|
std::vector<int> params { CAP_PROP_AUDIO_STREAM, 0, CAP_PROP_VIDEO_STREAM, -1 };
|
|
VideoCapture cap(0, cv::CAP_MSMF, params);
|
|
ASSERT_TRUE(cap.isOpened());
|
|
|
|
int samplesPerSecond = (int)cap.get(cv::CAP_PROP_AUDIO_SAMPLES_PER_SECOND);
|
|
const int audio_base_index = (int)cap.get(cv::CAP_PROP_AUDIO_BASE_INDEX);
|
|
|
|
const double cvTickFreq = cv::getTickFrequency();
|
|
int64 sysTimePrev = cv::getTickCount();
|
|
int64 sysTimeCurr = cv::getTickCount();
|
|
|
|
cout << "Audio would be captured for the next 10 seconds" << endl;
|
|
while ((sysTimeCurr-sysTimePrev)/cvTickFreq < 10)
|
|
{
|
|
if (cap.grab())
|
|
{
|
|
ASSERT_TRUE(cap.retrieve(frame, audio_base_index));
|
|
sysTimeCurr = cv::getTickCount();
|
|
}
|
|
}
|
|
validSize = samplesPerSecond*(int)((sysTimeCurr-sysTimePrev)/cvTickFreq);
|
|
cursize = (int)cap.get(cv::CAP_PROP_AUDIO_POS);
|
|
ASSERT_LT(validSize - cursize, cursize*0.05);
|
|
}
|
|
|
|
}} // namespace
|