def select_stream_by_typed_index(ffprobe_streams, index, codec_type=None):
    """will return the mixed position of a stream by codec type"""
    assert codec_type in ('audio', 'video')
    current_type_index = -1
    for stream in ffprobe_streams:
        if stream['codec_type'] == codec_type:
            current_type_index += 1
        if current_type_index == index:
            return int(stream['index'])
