jellyfin / jellyfin

The Free Software Media System
https://jellyfin.org
GNU General Public License v2.0
35.24k stars 3.2k forks source link

The API Route `/Audio/:itemId/Stream` returns `Content-Length`: 0 #13082

Open GreepTheSheep opened 1 day ago

GreepTheSheep commented 1 day ago

This issue respects the following points:

Description of the bug

The API Route /Audio/:itemId/Stream returns Content-Length: 0 and the audio stream is not returned

Adding a different container than the original one, the audio stream is correctly returned

Reproduction steps

  1. Grabbing the music item ID
  2. Connecting to the API route https://jellyfin.example.com\Audio\:itemId\Stream

What is the current bug behavior?

A empty audio file is returned

What is the expected correct behavior?

The audio file is returned and should streams

Jellyfin Server version

10.10.0+

Specify commit id

No response

Specify unstable release number

No response

Specify version number

No response

Specify the build version

10.10.3

Environment

- OS: Debian 11
- Linux Kernel: 6.1.0-27-amd64
- Virtualization: Docker
- Clients: Browser & Postman Client
- Browser: Chrome & Firefox
- FFmpeg Version: 7.0.2-Jellyfin
- Playback Method: Direct Play
- Hardware Acceleration: NVENC
- GPU Model: GTX1650
- Plugins: none
- Reverse Proxy: caddy
- Base URL: none
- Networking: Host
- Storage: local

Jellyfin logs

[13:58:22] [INF] [11] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: /usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G  -i file:"/media/music/Geoxor/Geoxor - Time of Waste/03 - Hate.flac" -threads 2 -vn -ab 256000 -ac 2 -acodec libfdk_aac -id3v2_version 3 -write_id3v1 1 -y "/config/transcodes/8f8657e28ad247bc5e323849e90eb446.flac"
[13:58:22] [ERR] [82] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: FFmpeg exited with code 234

FFmpeg logs

{"Protocol":0,"Id":"449cf7f7b215b5dce2d1d6935d09c7f7","Path":"/media/music/Geoxor/Geoxor - Time of Waste/03 - Hate.flac","EncoderPath":null,"EncoderProtocol":null,"Type":0,"Container":"flac","Size":30428629,"Name":"03 - Hate","IsRemote":false,"ETag":"ed90f9bdfe7bc929ed74018a8250ae66","RunTimeTicks":2376000000,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"UseMostCompatibleTranscodingProfile":false,"RequiresOpening":false,"OpenToken":null,"RequiresClosing":false,"LiveStreamId":null,"BufferMs":null,"RequiresLooping":false,"SupportsProbing":true,"VideoType":null,"IsoType":null,"Video3DFormat":null,"MediaStreams":[{"Codec":"flac","CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Rotation":null,"Comment":null,"TimeBase":"1/44100","CodecTimeBase":null,"Title":null,"VideoRange":0,"VideoRangeType":0,"VideoDoViTitle":null,"AudioSpatialFormat":0,"LocalizedUndefined":null,"LocalizedDefault":"Par d\u00E9faut","LocalizedForced":null,"LocalizedExternal":"Externe","LocalizedHearingImpaired":null,"DisplayTitle":"FLAC - Stereo","NalLengthSize":null,"IsInterlaced":false,"IsAVC":false,"ChannelLayout":"stereo","BitRate":1024532,"BitDepth":16,"RefFrames":null,"PacketLength":null,"Channels":2,"SampleRate":44100,"IsDefault":false,"IsForced":false,"IsHearingImpaired":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"ReferenceFrameRate":null,"Profile":null,"Type":0,"AspectRatio":null,"Index":0,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null},{"Codec":"mjpeg","CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":"bt470bg","ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Rotation":null,"Comment":"Cover (front)","TimeBase":"1/90000","CodecTimeBase":null,"Title":null,"VideoRange":0,"VideoRangeType":0,"VideoDoViTitle":null,"AudioSpatialFormat":0,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"LocalizedHearingImpaired":null,"DisplayTitle":null,"NalLengthSize":null,"IsInterlaced":false,"IsAVC":false,"ChannelLayout":null,"BitRate":null,"BitDepth":8,"RefFrames":1,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":false,"IsForced":false,"IsHearingImpaired":false,"Height":800,"Width":800,"AverageFrameRate":null,"RealFrameRate":90000,"ReferenceFrameRate":90000,"Profile":"Progressive","Type":3,"AspectRatio":"1:1","Index":1,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":"gray","Level":-99,"IsAnamorphic":false},{"Codec":null,"CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Rotation":null,"Comment":null,"TimeBase":null,"CodecTimeBase":null,"Title":null,"VideoRange":0,"VideoRangeType":0,"VideoDoViTitle":null,"AudioSpatialFormat":0,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"LocalizedHearingImpaired":null,"DisplayTitle":null,"NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":null,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":false,"IsForced":false,"IsHearingImpaired":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"ReferenceFrameRate":null,"Profile":null,"Type":5,"AspectRatio":null,"Index":2,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":"/config/metadata/library/44/449cf7f7b215b5dce2d1d6935d09c7f7/03 - Hate.txt","PixelFormat":null,"Level":null,"IsAnamorphic":null}],"MediaAttachments":[],"Formats":[],"Bitrate":1024532,"FallbackMaxStreamingBitrate":null,"Timestamp":null,"RequiredHttpHeaders":{},"TranscodingUrl":null,"TranscodingSubProtocol":0,"TranscodingContainer":null,"AnalyzeDurationMs":null,"DefaultAudioStreamIndex":null,"DefaultSubtitleStreamIndex":null,"HasSegments":false}

/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G  -i file:"/media/music/Geoxor/Geoxor - Time of Waste/03 - Hate.flac" -threads 2 -vn -ab 256000 -ac 2 -acodec libfdk_aac -id3v2_version 3 -write_id3v1 1 -y "/config/transcodes/8f8657e28ad247bc5e323849e90eb446.flac"

ffmpeg version 7.0.2-Jellyfin Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto=auto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libxml2 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libharfbuzz --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, flac, from 'file:/media/music/Geoxor/Geoxor - Time of Waste/03 - Hate.flac':
  Metadata:
    TITLE           : Hate
    ARTIST          : Geoxor
    ALBUM           : Time of Waste
    album_artist    : Geoxor
    track           : 3
    TRACKTOTAL      : 3
    disc            : 1
    DISCTOTAL       : 1
    GENRE           : Dance
    DATE            : 2018-07-10
    LENGTH          : 237000
    BPM             : 149.8
    PUBLISHER       : Geoxor
    ISRC            : QM42K1834599
    BARCODE         : 053000157588
    ITUNESADVISORY  : 0
    COMPOSER        : George Tsotsos
    COPYRIGHT       : Geoxor
  Duration: 00:03:57.60, start: 0.000000, bitrate: 1024 kb/s
  Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
  Stream #0:1: Video: mjpeg (Progressive), gray(bt470bg/unknown/unknown), 800x800 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
      Metadata:
        comment         : Cover (front)
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[flac @ 0x561aea4a9980] Invalid audio stream. Exactly one FLAC audio stream is required.
[out#0/flac @ 0x561aea4a7480] Could not write header (incorrect codec parameters ?): Invalid argument
[af#0:0 @ 0x561aea4aa200] Error sending frames to consumers: Invalid argument
[af#0:0 @ 0x561aea4aa200] Task finished with error code: -22 (Invalid argument)
[af#0:0 @ 0x561aea4aa200] Terminating thread with return code -22 (Invalid argument)
[libfdk_aac @ 0x561aea4ab400] Trying to remove 1024 samples, but the queue is empty
    Last message repeated 1 times
[out#0/flac @ 0x561aea4a7480] Nothing was written into output file, because at least one of its streams received no packets.
size=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

Client / Browser logs

Response headers on the request:

Image

Note: the server is proxied through Cloudflare, hence the Cf-* headers

Relevant screenshots or videos

No response

Additional information

No response

gnattu commented 1 day ago

The UniversalAudioController is now the recommended way to get audio streams, which is easier to use.

If you want to use the raw audio stream endpoint, the audioCodec query parameter is now required if you don't specify a container to the url. For example, it should be either stream?audioCodec=aac or stream.aac, and just use stream will get undefined behavior.

It was always undefined behavior, but the old undefined behavior could behave as if it was working correctly.