Skip to content

Commit

Permalink
Merge pull request #383 from valbok/empty-input
Browse files Browse the repository at this point in the history
Return source frames only if filter is set
  • Loading branch information
valbok authored Jul 17, 2023
2 parents 960a830 + b64866c commit 06224e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/QtAVPlayer/qavaudiofilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void QAVAudioFilter::read(QAVFrame &frame)
{
Q_D(QAVAudioFilter);
if (d->outputs.isEmpty() || d->isEmpty) {
frame = d->sourceFrame;
if (!d->outputs.isEmpty())
frame = d->sourceFrame;
d->sourceFrame = {};
d->isEmpty = true;
return;
Expand Down
3 changes: 2 additions & 1 deletion src/QtAVPlayer/qavvideofilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ void QAVVideoFilter::read(QAVFrame &frame)
{
Q_D(QAVVideoFilter);
if (d->outputs.isEmpty() || d->isEmpty) {
frame = d->sourceFrame;
if (!d->outputs.isEmpty())
frame = d->sourceFrame;
d->sourceFrame = {};
d->isEmpty = true;
return;
Expand Down
27 changes: 27 additions & 0 deletions tests/auto/integration/qavplayer/tst_qavplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private slots:
void filterName();
void filterNameStep();
void audioVideoFilter();
void audioFilterVideoFrames();
void inputFormat();
void inputVideoCodec();
void flushFilters();
Expand Down Expand Up @@ -2966,6 +2967,32 @@ void tst_QAVPlayer::audioVideoFilter()
QCOMPARE(frame.filterName(), "panel_4");
}

void tst_QAVPlayer::audioFilterVideoFrames()
{
qputenv("QT_AVPLAYER_NO_HWDEVICE", "1");
QAVPlayer p;
QFileInfo file(testData("test.mkv"));
p.setSource(file.absoluteFilePath());
p.setFilter("aformat=sample_fmts=flt|fltp,astats=metadata=1:reset=1:length=0.4,aphasemeter=video=0,ebur128=metadata=1,aformat=sample_fmts=flt|fltp");

int videoFramesCount = 0;
QObject::connect(&p, &QAVPlayer::videoFrame, &p, [&](const QAVVideoFrame &) {
++videoFramesCount;
}, Qt::DirectConnection);

int audioFramesCount = 0;
QObject::connect(&p, &QAVPlayer::audioFrame, &p, [&](const QAVAudioFrame &) {
++audioFramesCount;
}, Qt::DirectConnection);


p.setSynced(false);
p.play();
QTRY_COMPARE_WITH_TIMEOUT(p.mediaStatus(), QAVPlayer::EndOfMedia, 15000);
QCOMPARE(videoFramesCount, 0);
QVERIFY(audioFramesCount > 0);
}

void tst_QAVPlayer::inputFormat()
{
QAVPlayer p;
Expand Down

0 comments on commit 06224e8

Please sign in to comment.