core, demux: fix video index handling in stream switching