Move transcoding logic to a separate class