Multiple Media uploader output to input

As per comments try collecting the ids in an array and then setting the text field once:

            custom_uploader.on('select', function() {
                var selection = custom_uploader.state().get('selection');
                var ids = selection.map( function (attachment) {
                    return attachment.id;
                });
                $("#media-input").val(ids.join(','));
            });