I'm trying to create an iterator of video frames from a packetiter. I need to filter out packets that are not from the video stream as in a video file there are multiple streams, audio, video etc
Let's say I have variable index
which is the index of the stream i want to decode and I want to only decode packets from that stream
This gives me the following iterator everything past the filter iterator has been elided
let index = self.video_index; // unused variable Index
self.input
.packets()
.filter(|(stream, _packet)| match stream.index() {
index => true, //unused variable index
_ => false,
})
Now the predicate function for .filter can't access the outer scope. I don't know what index will be beforehand. How can I get the predicate function to match on stream.index() when index does not exist in the predicate's scope?