-
Notifications
You must be signed in to change notification settings - Fork 281
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
base: master
Are you sure you want to change the base?
Conversation
@@ -412,7 +412,7 @@ struct Filter | |||
} | |||
} | |||
|
|||
std::vector<AVStream*> av_streams; | |||
std::deque<unsigned> video_streams, audio_streams; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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*
.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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).
62fb5ad
to
8101b3b
Compare
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.