Docker container can no longer receive Opus tracks via federation in 1.0.1
/label Type: Bug Status: Need triage
Steps to reproduce
- Install Funkwhale 1.0.1 in multi-container Docker mode.
- Federate https://tanukitunes.com/federation/music/libraries/34b758c5-0136-4fb9-924b-8e3863fe70e6
- Play https://tanukitunes.com/library/tracks/77038/ via the local instance.
What happens?
The track does not play.
The server logs report something like:
fw-nginx_1 | 172.16.238.6 - - [11/Nov/2020:00:22:10 +0000] "GET /api/v1/listen/af429245-e044-458c-a548-6bd8a2c79ae3/?to=mp3&token=eyJ1c2VyX2lkIjoxLCJ1c2VyX3NlY3JldCI6ImJkZWY2ZDc0LWQyNTMtNDQxNS04OT
VlLTBhYTcyZmEyM2Y1NiIsInNjb3BlcyI6WyJyZWFkOmxpYnJhcmllcyJdfQ:1kcdrV:_Qi64nuKc0CqdjHubpzL1I9C72Q HTTP/1.1" 504 167 "https://music.novak.network/library/albums/5638/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64
; rv:82.0) Gecko/20100101 Firefox/82.0" "10.1.0.1"
fw-api_1 | 2020-11-11 00:23:03,242 django.request ERROR Internal Server Error: /api/v1/listen/af429245-e044-458c-a548-6bd8a2c79ae3/
fw-api_1 | Traceback (most recent call last):
fw-api_1 | File "/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
fw-api_1 | response = get_response(request)
fw-api_1 | File "/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
fw-api_1 | response = self.process_exception_by_middleware(e, request)
fw-api_1 | File "/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
fw-api_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
fw-api_1 | File "/usr/lib/python3.7/contextlib.py", line 74, in inner
fw-api_1 | return func(*args, **kwds)
fw-api_1 | File "/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
fw-api_1 | return view_func(*args, **kwargs)
fw-api_1 | File "/venv/lib/python3.7/site-packages/rest_framework/viewsets.py", line 114, in view
fw-api_1 | return self.dispatch(request, *args, **kwargs)
fw-api_1 | File "/venv/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
fw-api_1 | response = self.handle_exception(exc)
fw-api_1 | File "/venv/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
fw-api_1 | self.raise_uncaught_exception(exc)
fw-api_1 | File "/venv/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
fw-api_1 | raise exc
fw-api_1 | File "/venv/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
fw-api_1 | response = handler(request, *args, **kwargs)
fw-api_1 | File "/app/funkwhale_api/music/views.py", line 638, in retrieve
fw-api_1 | return handle_stream(track, request, **config)
fw-api_1 | File "/app/funkwhale_api/music/views.py", line 666, in handle_stream
fw-api_1 | wsgi_request=request._request,
fw-api_1 | File "/app/funkwhale_api/music/views.py", line 536, in inner
fw-api_1 | response = f(*args, **kwargs)
fw-api_1 | File "/app/funkwhale_api/music/views.py", line 591, in handle_serve
fw-api_1 | transcoded_version = f.get_transcoded_version(format, max_bitrate=max_bitrate)
fw-api_1 | File "/app/funkwhale_api/music/models.py", line 927, in get_transcoded_version
fw-api_1 | File "/app/funkwhale_api/music/models.py", line 927, in get_transcoded_version
fw-api_1 | return self.create_transcoded_version(mimetype, format, bitrate=max_bitrate)
fw-api_1 | File "/usr/lib/python3.7/contextlib.py", line 74, in inner
fw-api_1 | return func(*args, **kwds)
fw-api_1 | File "/app/funkwhale_api/music/models.py", line 942, in create_transcoded_version
fw-api_1 | audio=self.get_audio_segment(),
fw-api_1 | File "/app/funkwhale_api/music/models.py", line 859, in get_audio_segment
fw-api_1 | audio = pydub.AudioSegment.from_file(input, format=input_format)
fw-api_1 | File "/venv/lib/python3.7/site-packages/pydub/audio_segment.py", line 725, in from_file
fw-api_1 | p.returncode, p_err.decode(errors='ignore') ))
fw-api_1 | pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 0
fw-api_1 |
fw-api_1 | Output from ffmpeg/avlib:
fw-api_1 |
fw-api_1 | ffmpeg version 4.1.6 Copyright (c) 2000-2020 the FFmpeg developers
fw-api_1 | built with gcc 8.3.0 (Alpine 8.3.0)
fw-api_1 | configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug
fw-api_1 | libavutil 56. 22.100 / 56. 22.100
fw-api_1 | libavcodec 58. 35.100 / 58. 35.100
fw-api_1 | libavformat 58. 20.100 / 58. 20.100
fw-api_1 | libavdevice 58. 5.100 / 58. 5.100
fw-api_1 | libavfilter 7. 40.101 / 7. 40.101
fw-api_1 | libavresample 4. 0. 0 / 4. 0. 0
fw-api_1 | libswscale 5. 3.100 / 5. 3.100
fw-api_1 | libswresample 3. 3.100 / 3. 3.100
fw-api_1 | libpostproc 55. 3.100 / 55. 3.100
fw-api_1 | Unknown input format: 'opus'
fw-api_1 |
What is expected?
This track played fine on 0.21.2, and ought to still work.
Context
Funkwhale version(s) affected: 1.0.1
Weirdly, trying to transcode what I think is the same file manually works:
docker run -it --rm funkwhale/funkwhale:1.0.1 /bin/sh
wget https://tanukitunes.com/api/v1/listen/a8412dfd-7c7c-44d6-bc37-e97d128da538/?upload=3b0e4616-da64-4e0f-a14c-3af328c5b680
mv '?upload=3b0e4616-da64-4e0f-a14c-3af328c5b680' track.opus
ffmpeg -i track.opus track.mp3
I can replicatee the reported message if I instead do:
ffmpeg -f opus -i track.opus track.mp3
The appropriate input format to use here appears to be -f ogg
and not -f opus
. ffmpeg apparently only understands opus as an output format, according to ffmpeg -formats
. -f ogg
reads both Opus and Vorbis files with Ogg containers, but for writing you use -f opus
for Opus-in-Ogg, and -f ogg
for Vorbis-in-Ogg.
This can't work here where we try to determine the input format, because a Pydub/ffmpeg input format does not map one to one with an extension. Opus files have a .opus extension but are in Ogg format: