mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 01:39:18 +02:00
See #272: added preference and base logic for transcoding
This commit is contained in:
parent
baf5a350b3
commit
2fe1e7c950
6 changed files with 161 additions and 9 deletions
|
@ -2,8 +2,10 @@ import mimetypes
|
|||
|
||||
import magic
|
||||
import mutagen
|
||||
import pydub
|
||||
|
||||
from funkwhale_api.common.search import normalize_query, get_query # noqa
|
||||
from funkwhale_api.common import utils
|
||||
|
||||
|
||||
def guess_mimetype(f):
|
||||
|
@ -68,3 +70,10 @@ def get_actor_from_request(request):
|
|||
actor = request.user.actor
|
||||
|
||||
return actor
|
||||
|
||||
|
||||
def transcode_file(input, output, input_format, output_format, **kwargs):
|
||||
with input.open("rb"):
|
||||
audio = pydub.AudioSegment.from_file(input, format=input_format)
|
||||
with output.open("wb"):
|
||||
return audio.export(output, format=output_format, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue