Jellyfin: Transcoding produces weird bitrate and sample rate

debug.log (622.7 KB)

Issue description:

The transcoded files from a Jellyfin server have a weird bitrate and sample rate. I set 320kbps as the transcoding target. Doing a download of a normal flac 16 bit 44kHz for offline playback, I get a Ogg with about 135 kB/s and 48,0 kHz. While I understand that I might not get an exact bitrate when transcoding, 135 kB/s seems rather low. But changing/increasing the sample rate seems like a bad thing. The Symfonium log is attached (includes some transcoding and then going offline and checking; I replace my server’s URL for paranoia reasons).
Checking the Jellyfin log, the ffmpeg command run by Jellyfin shows what I get in the end so at least this is consistent:

/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M  -i file:"THE_FLAC_FILE" -threads 0 -vn -ab 128000 -ac 2 -ar 48000 -id3v2_version 3 -write_id3v1 1 -y "/transcodes/512417ce058e23fa0892f4896c271f86.opus"

So is Jellyfin to be blamed?

Yes it’s them tried to report once got no result.

I send the proper transcoding profile

{
  "deviceProfile": {
    "MaxStreamingBitrate": 327680,
    "MaxStaticBitrate": 327680,
    "MusicStreamingTranscodingBitrate": 327680,
    "TranscodingProfiles": [
      {
        "Container": "opus",
        "Type": "Audio",
        "AudioCodec": "opus",
        "Context": "Streaming",
        "Protocol": "http",
        "MaxAudioChannels": "6",
        "MinSegments": 0,
        "VideoCodec": ""
      },
      {
        "Container": "mp3",
        "Type": "Audio",
        "AudioCodec": "mp3",
        "Context": "Static",
        "Protocol": "http",
        "MaxAudioChannels": "6",
        "MinSegments": 0,
        "VideoCodec": ""
      },
      {
        "Container": "mp3",
        "Type": "Audio",
        "AudioCodec": "mp3",
        "Context": "Streaming",
        "Protocol": "http",
        "MaxAudioChannels": "6",
        "MinSegments": 0,
        "VideoCodec": ""
      }
    ],
    "CodecProfiles": [
      {
        "Type": "VideoAudio",
        "Conditions": [
          {
            "Condition": "Equals",
            "Property": "IsSecondaryAudio",
            "Value": "false",
            "IsRequired": false
          }
        ],
        "Codec": "",
        "Container": ""
      }
    ]
  }
}

They give the proper url with the proper bitrate.

{
  "MediaSources": [
    {
      "Protocol": "File",
      "Id": "239f0898e8daeb5e66bdf1ef4da4d858",
      "Path": "\\\\music\\Einzelne Künstler\\Danny Elfman\\Spider-Man 2_ Original Motion Picture Score (2004)\\(05) Danny Elfman - A Phone Call _ The Wrong Kiss _ Peter's Birthday.flac",
      "Type": "Default",
      "Container": "flac",
      "Size": 9786209,
      "Name": "(05) Danny Elfman - A Phone Call _ The Wrong Kiss _ Peter's Birthday",
      "IsRemote": false,
      "ETag": "3b9d23431d1cfc64faeb19d2a14c2969",
      "RunTimeTicks": 1267600000,
      "ReadAtNativeFramerate": false,
      "IgnoreDts": false,
      "IgnoreIndex": false,
      "GenPtsInput": false,
      "SupportsTranscoding": true,
      "SupportsDirectStream": false,
      "SupportsDirectPlay": false,
      "IsInfiniteStream": false,
      "RequiresOpening": false,
      "RequiresClosing": false,
      "RequiresLooping": false,
      "SupportsProbing": true,
      "MediaStreams": [
        {
          "Codec": "flac",
          "TimeBase": "1/44100",
          "CodecTimeBase": "1/44100",
          "DisplayTitle": "FLAC - Stereo",
          "IsInterlaced": false,
          "ChannelLayout": "stereo",
          "BitRate": 617621,
          "BitDepth": 16,
          "Channels": 2,
          "SampleRate": 44100,
          "IsDefault": false,
          "IsForced": false,
          "Type": "Audio",
          "Index": 0,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Level": 0
        },
        {
          "Codec": "mjpeg",
          "ColorSpace": "bt470bg",
          "Comment": "Cover (front)",
          "TimeBase": "1/90000",
          "CodecTimeBase": "0/1",
          "IsInterlaced": false,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": false,
          "IsForced": false,
          "Height": 500,
          "Width": 500,
          "RealFrameRate": 90000,
          "Profile": "Baseline",
          "Type": "EmbeddedImage",
          "AspectRatio": "1:1",
          "Index": 1,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "PixelFormat": "yuvj420p",
          "Level": -99
        }
      ],
      "MediaAttachments": [],
      "Formats": [],
      "Bitrate": 617621,
      "RequiredHttpHeaders": {},
      "TranscodingUrl": "/audio/239f0898-e8da-eb5e-66bd-f1ef4da4d858/stream.opus?DeviceId=14E18F78A72CBEBD8A7370C6F4F92654&MediaSourceId=239f0898e8daeb5e66bdf1ef4da4d858&AudioBitrate=327680&PlaySessionId=7a2cea0d31064bc287eea8c0489fabc1&api_key=REDACTED&TranscodingMaxAudioChannels=6&RequireAvc=false&Tag=3b9d23431d1cfc64faeb19d2a14c2969&TranscodeReasons=ContainerNotSupported,%20VideoCodecNotSupported,%20AudioCodecNotSupported",
      "TranscodingSubProtocol": "http",
      "TranscodingContainer": "opus"
    }
  ],
  "PlaySessionId": "7a2cea0d31064bc287eea8c0489fabc1"
}

And when requesting that url they reduce to 128kbps.

Thanks for the quick reply. It might be that the 128kbps is the default setting here. I will try to get an answer from them.

Yes but it should never reach that point it should return from jellyfin/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs at 469b01e18e0a1aed92de9032d20e0afb76714dcb · jellyfin/jellyfin · GitHub since all the proper params are passed and from an url they provide.