refactor video codec selection