Often stream and a demuxer are opened at the same time. Provide a function for this and replace most of its uses.