Skip to content

modules/ffmpeg/producer: fix stream to filter input assignment #1633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

programmerjake
Copy link
Contributor

Fixes: #1632

This also adds more checks before trying to activate alphamerge mode, checking that the dimensions, sample aspect ratio, and field order match. It also checks that if there's 3 or more video streams that only the largest two are matching, since if there's 3 or more matching that seems more likely to be unrelated video streams than color and alpha streams.

@@ -412,7 +412,7 @@ struct Filter
}
}

std::vector<AVStream*> av_streams;
std::deque<unsigned> video_streams, audio_streams;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not store AVStream* and avoid extra indirection later on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we need the stream index later, also having the element type not be AVStream * helps avoid the bug that I'm fixing from recurring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @programmerjake. I believe you can still fix the bug even if you stick with AVStream*, unless I've missed something. BTW, you can extract index from AVStream*.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but imo it's good to make it harder to mess up in the future because if you tried to misuse it like how it was, it would compile error this way.

std::copy_if(av_streams.begin(), av_streams.end(), std::back_inserter(video_av_streams), [](auto s) {
return s->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
std::stable_sort(video_streams.begin(), video_streams.end(), [&](unsigned lhs, unsigned rhs) {
return input->streams[lhs]->codecpar->height > input->streams[rhs]->codecpar->height;
Copy link
Contributor

@dimitry-ishenko dimitry-ishenko May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can avoid extra indirection here (see above comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: logic errors in Filter::Filter when handling stream indexes
2 participants