diff --git a/api/funkwhale_api/federation/serializers.py b/api/funkwhale_api/federation/serializers.py
index 00bb7d45b0b1b98176d74f58075866392a53898c..38efdd3bf76fad277b6a6d9ea7836b18619a9aa8 100644
--- a/api/funkwhale_api/federation/serializers.py
+++ b/api/funkwhale_api/federation/serializers.py
@@ -1,3 +1,4 @@
+import logging
 import urllib.parse
 
 from django.urls import reverse
@@ -21,6 +22,8 @@ AP_CONTEXT = [
     {},
 ]
 
+logger = logging.getLogger(__name__)
+
 
 class ActorSerializer(serializers.Serializer):
     id = serializers.URLField()
@@ -620,6 +623,8 @@ class CollectionPageSerializer(serializers.Serializer):
         for i in raw_items:
             if i.is_valid():
                 valid_items.append(i)
+            else:
+                logger.debug('Invalid item %s: %s', i.data, i.errors)
 
         return valid_items
 
diff --git a/api/funkwhale_api/music/management/__init__.py b/api/funkwhale_api/music/management/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/api/funkwhale_api/music/management/commands/__init__.py b/api/funkwhale_api/music/management/commands/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/api/funkwhale_api/music/management/commands/fix_track_files.py b/api/funkwhale_api/music/management/commands/fix_track_files.py
new file mode 100644
index 0000000000000000000000000000000000000000..f68bcf1359d4661710a98ee443ff1578824f46f2
--- /dev/null
+++ b/api/funkwhale_api/music/management/commands/fix_track_files.py
@@ -0,0 +1,45 @@
+import cacheops
+import os
+
+from django.db import transaction
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
+
+from funkwhale_api.music import models, utils
+
+
+class Command(BaseCommand):
+    help = 'Run common checks and fix against imported tracks'
+
+    def add_arguments(self, parser):
+        parser.add_argument(
+            '--dry-run',
+            action='store_true',
+            dest='dry_run',
+            default=False,
+            help='Do not execute anything'
+        )
+
+    def handle(self, *args, **options):
+        if options['dry_run']:
+            self.stdout.write('Dry-run on, will not commit anything')
+        self.fix_mimetypes(**options)
+        cacheops.invalidate_model(models.TrackFile)
+
+    @transaction.atomic
+    def fix_mimetypes(self, dry_run, **kwargs):
+        self.stdout.write('Fixing missing mimetypes...')
+        matching = models.TrackFile.objects.filter(
+            source__startswith='file://', mimetype=None)
+        self.stdout.write(
+            '[mimetypes] {} entries found with no mimetype'.format(
+                matching.count()))
+        for extension, mimetype in utils.EXTENSION_TO_MIMETYPE.items():
+            qs = matching.filter(source__endswith='.{}'.format(extension))
+            self.stdout.write(
+                '[mimetypes] setting {} {} files to {}'.format(
+                    qs.count(), extension, mimetype
+                ))
+            if not dry_run:
+                self.stdout.write('[mimetypes] commiting...')
+                qs.update(mimetype=mimetype)
diff --git a/api/funkwhale_api/music/tasks.py b/api/funkwhale_api/music/tasks.py
index f2244d78527c5feff7248b9a40c083ea71498891..aaaa2cdca12539808b6bf1554a946d4dfbb9ae30 100644
--- a/api/funkwhale_api/music/tasks.py
+++ b/api/funkwhale_api/music/tasks.py
@@ -1,3 +1,5 @@
+import os
+
 from django.core.files.base import ContentFile
 
 from dynamic_preferences.registries import global_preferences_registry
@@ -13,6 +15,7 @@ from funkwhale_api.providers.audiofile.tasks import import_track_data_from_path
 from django.conf import settings
 from . import models
 from . import lyrics as lyrics_utils
+from . import utils as music_utils
 
 
 @celery.app.task(name='acoustid.set_on_track_file')
@@ -129,6 +132,10 @@ def _do_import(import_job, replace=False, use_acoustid=True):
     elif not import_job.audio_file and not import_job.source.startswith('file://'):
         # not an implace import, and we have a source, so let's download it
         track_file.download_file()
+    elif not import_job.audio_file and import_job.source.startswith('file://'):
+        # in place import, we set mimetype from extension
+        path, ext = os.path.splitext(import_job.source)
+        track_file.mimetype = music_utils.get_type_from_ext(ext)
     track_file.save()
     import_job.status = 'finished'
     import_job.track_file = track_file
diff --git a/api/funkwhale_api/music/utils.py b/api/funkwhale_api/music/utils.py
index 7a851f7cc35e17681293a9e3a1c24d6cc1e64998..49a63930349a081178bc36c87e73a702e4d9faac 100644
--- a/api/funkwhale_api/music/utils.py
+++ b/api/funkwhale_api/music/utils.py
@@ -63,8 +63,21 @@ def compute_status(jobs):
     return 'finished'
 
 
+AUDIO_EXTENSIONS_AND_MIMETYPE = [
+    ('ogg', 'audio/ogg'),
+    ('mp3', 'audio/mpeg'),
+]
+
+EXTENSION_TO_MIMETYPE = {ext: mt for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
+MIMETYPE_TO_EXTENSION = {mt: ext for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
+
+
 def get_ext_from_type(mimetype):
-    mapping = {
-        'audio/ogg': 'ogg',
-        'audio/mpeg': 'mp3',
-    }
+    return MIMETYPE_TO_EXTENSION.get(mimetype)
+
+
+def get_type_from_ext(extension):
+    if extension.startswith('.'):
+        # we remove leading dot
+        extension = extension[1:]
+    return EXTENSION_TO_MIMETYPE.get(extension)
diff --git a/api/tests/music/test_import.py b/api/tests/music/test_import.py
index 65e0242fb013785b0eb21e29ac9259512b281392..fa1c98eb4ca78c7e9fab5861989852687d764f03 100644
--- a/api/tests/music/test_import.py
+++ b/api/tests/music/test_import.py
@@ -243,3 +243,4 @@ def test__do_import_in_place_mbid(factories, tmpfile):
 
     assert bool(tf.audio_file) is False
     assert tf.source == 'file:///test.ogg'
+    assert tf.mimetype == 'audio/ogg'
diff --git a/changes/changelog.d/183.bugfix b/changes/changelog.d/183.bugfix
new file mode 100644
index 0000000000000000000000000000000000000000..03a28e9c394e73fe679c47f573aa879343918dd4
--- /dev/null
+++ b/changes/changelog.d/183.bugfix
@@ -0,0 +1 @@
+Ensure in place imported files get a proper mimetype (#183)
diff --git a/changes/changelog.d/183.enhancement b/changes/changelog.d/183.enhancement
new file mode 100644
index 0000000000000000000000000000000000000000..2549db810c97283c1ea7ef246ea79dc5a4ced674
--- /dev/null
+++ b/changes/changelog.d/183.enhancement
@@ -0,0 +1 @@
+Added a fix_track_files command to run checks and fixes against library (#183)