diff --git a/src/QtAVPlayer/qavaudiofilter.cpp b/src/QtAVPlayer/qavaudiofilter.cpp index 177fb90e..dd4da492 100644 --- a/src/QtAVPlayer/qavaudiofilter.cpp +++ b/src/QtAVPlayer/qavaudiofilter.cpp @@ -61,7 +61,7 @@ int QAVAudioFilter::write(const QAVFrame &frame) AVFrame *decoded_frame = frame.frame(); AVRational decoded_frame_tb = frame.stream().stream()->time_base; // TODO: clear filter_in_rescale_delta_last - if (decoded_frame->pts != AV_NOPTS_VALUE) { + if (!d->inputs.isEmpty() && decoded_frame->pts != AV_NOPTS_VALUE) { decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, AVRational{1, decoded_frame->sample_rate}, decoded_frame->nb_samples, @@ -111,6 +111,7 @@ int QAVAudioFilter::read(QAVFrame &frame) if (out.frame()->duration == AV_NOPTS_VALUE || out.frame()->duration == 0) out.frame()->duration = d->sourceFrame.frame()->duration; #endif + out.setFrameRate(av_buffersink_get_frame_rate(filter.ctx())); out.setTimeBase(av_buffersink_get_time_base(filter.ctx())); out.setFilterName( !filter.name().isEmpty() diff --git a/tests/auto/integration/qavplayer/tst_qavplayer.cpp b/tests/auto/integration/qavplayer/tst_qavplayer.cpp index b798faf1..36b9c389 100644 --- a/tests/auto/integration/qavplayer/tst_qavplayer.cpp +++ b/tests/auto/integration/qavplayer/tst_qavplayer.cpp @@ -91,6 +91,7 @@ private slots: void audioVideoFilter(); void audioFilterVideoFrames(); void multipleFilters(); + void multipleAudioVideoFilters(); void inputFormat(); void inputVideoCodec(); void flushFilters(); @@ -3042,6 +3043,42 @@ void tst_QAVPlayer::multipleFilters() QCOMPARE(framesCount["panel_4"], 1); } +void tst_QAVPlayer::multipleAudioVideoFilters() +{ + qputenv("QT_AVPLAYER_NO_HWDEVICE", "1"); + QAVPlayer p; + QFileInfo file(testData("test_5beeps.mkv")); + p.setSource(file.absoluteFilePath()); + QList filters = { + "signalstats=stat=tout+vrep+brng [stats]", + "aformat=sample_fmts=flt|fltp,astats=metadata=1:reset=1:length=0.4,aphasemeter=video=0,ebur128=metadata=1,aformat=sample_fmts=flt|fltp [audio]", + }; + + QMap framesCount; + QAVVideoFrame videoFrame; + QObject::connect(&p, &QAVPlayer::videoFrame, &p, [&](const QAVVideoFrame &f) { + videoFrame = f; + ++framesCount[f.filterName()]; + }, Qt::DirectConnection); + + QAVAudioFrame audioFrame; + QObject::connect(&p, &QAVPlayer::audioFrame, &p, [&](const QAVAudioFrame &f) { + audioFrame = f; + ++framesCount[f.filterName()]; + }, Qt::DirectConnection); + + p.setSynced(false); + p.setFilters(filters); + p.play(); + QTRY_COMPARE_WITH_TIMEOUT(p.mediaStatus(), QAVPlayer::EndOfMedia, 15000); + QVERIFY(framesCount.contains("stats")); + QCOMPARE(framesCount["stats"], 125); + QCOMPARE(videoFrame.pts(), 4.963); + QVERIFY(framesCount.contains("audio")); + QCOMPARE(framesCount["audio"], 51); + QVERIFY(audioFrame.pts() < 5.5); +} + void tst_QAVPlayer::inputFormat() { QAVPlayer p; diff --git a/tests/auto/integration/testdata/test_5beeps.mkv b/tests/auto/integration/testdata/test_5beeps.mkv new file mode 100644 index 00000000..ea2cb75e Binary files /dev/null and b/tests/auto/integration/testdata/test_5beeps.mkv differ