manuakky resolving stuff
This commit is contained in:
parent
b55d9e3d8e
commit
981c61de8a
|
@ -4,10 +4,10 @@ import pathlib
|
||||||
|
|
||||||
import magic
|
import magic
|
||||||
import mutagen
|
import mutagen
|
||||||
|
import pydub
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from ffmpeg import FFmpeg
|
|
||||||
|
|
||||||
from funkwhale_api.common import throttling
|
from funkwhale_api.common import throttling
|
||||||
from funkwhale_api.common.search import get_fts_query # noqa
|
from funkwhale_api.common.search import get_fts_query # noqa
|
||||||
|
@ -102,10 +102,15 @@ def get_actor_from_request(request):
|
||||||
return actor
|
return actor
|
||||||
|
|
||||||
|
|
||||||
def transcode_audio(audio_file_path, output_path, output_format="mp3", **kwargs):
|
def transcode_file(input, output, input_format=None, output_format="mp3", **kwargs):
|
||||||
FFmpeg().input(audio_file_path).output(
|
with input.open("rb"):
|
||||||
output_path, format=output_format, **kwargs
|
audio = pydub.AudioSegment.from_file(input, format=input_format)
|
||||||
).option("y").execute()
|
return transcode_audio(audio, output, output_format, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def transcode_audio(audio, output, output_format, **kwargs):
|
||||||
|
with output.open("wb"):
|
||||||
|
return audio.export(output, format=output_format, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def increment_downloads_count(upload, user, wsgi_request):
|
def increment_downloads_count(upload, user, wsgi_request):
|
||||||
|
|
Loading…
Reference in New Issue