我使用Docker运行Django-Backend。我想将大型.mkv视频上传到后端,但将其转换并存储为.mp4
我应该如何进行?由于这最终将在kubernetes集群上运行,因此我应该生成执行该任务的docker-worker实例吗?
通常我会跑步
ffmpeg -i input.mkv -codec copy output.mp4
通过python的os-module,但我不想使django容器超载。
我使用以下内容上传.mkv视频:
models.py
class Record(models.Model):
name = models.CharField(max_length=255)
...
video = models.FileField(null=True, upload_to='uploads/')
serializers.py
class VideoSerializer(serializers.ModelSerializer):
class Meta:
model = Record
fields = ('id', 'video')
read_only_fields = ('id',)
views.py
...
@action(methods=['POST'], detail=True, url_path='upload-video')
def upload(self, request, pk=None):
record = self.get_object()
serializer = self.get_serializer(
record,
data=request.data
)
serializer.save()
return Response(serializer.data,status=status.HTTP_200_OK)
)