Jump to content

Audio HLS with TranscodingContainer=mp4: the playlist is served, the segments throw a 500


Recommended Posts

vdatanet
Posted

On Emby 4.9.5.0, requesting an audio HLS stream with fMP4 segments produces a correct playlist whose segments cannot be fetched. Every segment request — and the init segment — returns:

HTTP 500  "Object reference not set to an instance of an object."

The same request with TranscodingContainer=ts works. Same code, same token, same track; the only thing that changes is the container.

GET /Audio/{itemId}/universal
    ?UserId={userId}&DeviceId={deviceId}
    &MaxStreamingBitrate=192000
    &Container=mp3,aac,m4a,flac
    &AudioCodec=aac
    &TranscodingProtocol=hls
    &TranscodingContainer=mp4          <-- ts works, mp4 does not
    &MaxSampleRate=48000
    &PlaySessionId={uuid}
    &api_key={token}

Follow the master playlist to main.m3u8, then request either the #EXT-X-MAP init segment or any hls1/main/N.mp4, carrying the auth query params through as usual. Retried over several seconds in case it was a transcoder warm-up: it is not, the 500 is immediate and consistent.

Worth saying plainly: the playlist itself is authored correctly — version 7, an EXT-X-MAP pointing at init.mp4, segment durations, the lot. Whatever is missing looks like it sits between the playlist writer and the segment handler.

Two small things that might narrow it down, or might be irrelevant — you'll know which:

The ts and mp4 playlists are generated from the same request and differ exactly as you'd expect (version 3 vs 7, EXT-X-MAP present only on the second), so playlist generation looks complete.

The 500 is identical for init.mp4 and for every media segment, which suggests it's one path rather than a per-segment condition.

That's the whole report. I'm not asking for a feature here — just flagging that a route the server advertises can't be followed.

  • Thanks 1
vdatanet
Posted (edited)

The 500 is not a transcoding failure — ffmpeg is never launched. The server log shows FfRunException wrapping a NullReferenceException from Emby.Server.MediaEncoding.Unified.Ffmpeg, with no ffmpeg log entry at all. So the null is dereferenced while assembling the run for fmp4 segments, before any process starts.

And it looks specific to audio-only output. The same server, same version, same fMP4 container, but a movie instead of a track:

Playlist    Init    First segment
Video    v7 + EXT-X-MAP    ✅ 1,317 B    ✅ 234,856 B
Audio    v7 + EXT-X-MAP    ❌ 500    ❌ 500
So fMP4 segments are served fine here — just not for an audio-only stream.

Edited by vdatanet
vdatanet
Posted
5 minutes ago, Luke said:

Hi there, please attach the Emby server log from when the problem occurred:

2026-08-05 17:33:16.177 Info DynamicHlsService-0HNNIK2IOFT82:00000001: http/1.1 GET http://SERVER/Audio/2902/hls1/main/init.mp4?PlaySessionId=REDACTED&api_key=REDACTED. Source Ip: CLIENT,, Connection=close, Host=SERVER, User-Agent=REDACTED, Accept-Encoding=identity
2026-08-05 17:33:16.178 Info DynamicHlsService-0HNNIK2IOFT82:00000001: Starting transcoding because currentTranscodingIndex=null
2026-08-05 17:33:16.218 Error DynamicHlsService-0HNNIK2IOFT82:00000001: Error processing request
    *** Error Report ***
    Version: 4.9.5.0
    Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
    Operating system: Linux version 6.8.0-137-generic (buildd@lcy02-amd64-064) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0, GNU ld (GNU Binutils for Ub
    OS/Process: x64/x64
    Framework: .NET 8.0.25
    Runtime: opt/emby-server/system/System.Private.CoreLib.dll
    Processor count: 6
    Data path: /var/lib/emby
    Application path: /opt/emby-server/system
    Emby.Server.MediaEncoding.Unified.Ffmpeg.FfRunException: Emby.Server.MediaEncoding.Unified.Ffmpeg.FfRunException: Object reference not set to an instance of an object.
    
    
    
    
     ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Emby.Server.MediaEncoding.Encoder.TranscodingCommandBuilder.HlsGetCommandLineArguments(String outputPath, StreamState state, Int32 startNumber, hls_playlist_typeEnum playlistType, String segmentListEntryPrefix, String segmentFileExtension)
       at Emby.Server.MediaEncoding.Api.Hls.DynamicHlsService.GetCommandLineArguments(String outputPath, StreamState state)
       at Emby.Server.MediaEncoding.Api.BaseStreamingService.StartFfMpeg(StreamState state, String outputPath, CancellationToken cancellationToken, Boolean acquireResources)
       --- End of inner exception stack trace ---
       at Emby.Server.MediaEncoding.Api.BaseStreamingService.StartFfMpeg(StreamState state, String outputPath, CancellationToken cancellationToken, Boolean acquireResources)
       at Emby.Server.MediaEncoding.Api.Hls.DynamicHlsService.GetDynamicSegment(StreamRequest request, String manifestAbsoluteUri, String playlistId, String segmentId, Int32 subtitleStreamIndex, AuthorizationInfo authorizationInfo)
       at Emby.Server.Implementations.Services.ServiceController.GetTaskResult(Task task)
       at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost httpHost, IServerApplicationHost appHost, IRequest httpReq, IResponse httpRes, IStreamHelper streamHelper, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
       at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, RestPath restPath, String urlString, String localPath, String contentTypeInPath, CancellationToken cancellationToken)
    Source: Emby.Server.MediaEncoding
    TargetSite: Void MoveNext()
    InnerException: System.NullReferenceException: Object reference not set to an instance of an object.
    Source: Emby.Server.MediaEncoding
    TargetSite: Emby.Ffmpeg.Model.FfmpegCommand HlsGetCommandLineArguments(System.String, Emby.Server.MediaEncoding.Api.StreamState, Int32, hls_playlist_typeEnum, System.String, System.String)
       at Emby.Server.MediaEncoding.Encoder.TranscodingCommandBuilder.HlsGetCommandLineArguments(String outputPath, StreamState state, Int32 startNumber, hls_playlist_typeEnum playlistType, String segmentListEntryPrefix, String segmentFileExtension)
       at Emby.Server.MediaEncoding.Api.Hls.DynamicHlsService.GetCommandLineArguments(String outputPath, StreamState state)
       at Emby.Server.MediaEncoding.Api.BaseStreamingService.StartFfMpeg(StreamState state, String outputPath, CancellationToken cancellationToken, Boolean acquireResources)
    
2026-08-05 17:33:16.218 Info DynamicHlsService-0HNNIK2IOFT82:00000001: http/1.1 Response 500 to CLIENT. Time: 41ms. GET http://SERVER/Audio/2902/hls1/main/init.mp4?PlaySessionId=REDACTED&api_key=REDACTED. Headers: Connection=close, Content-Type=text/plain, Date=Wed, 05 Aug 2026 17:33:15 GMT, Server=UPnP/1.0 DLNADOC/1.50, Content-Length=57, Cross-Origin-Resource-Policy=cross-origin, Private-Network-Access-Name=REDACTED, Private-Network-Access-Id=REDACTED

  • 4 weeks later...
vdatanet
Posted

Coming back to this one with a fresh measurement, because I had a 4.10.0.30 container up for
another thread and this took two minutes to check: it still happens on the current beta.

Setup: clean install in a disposable container, 4.10.0.30, nothing from my own server. The
source is synthetic — 90 s of pink noise in FLAC at 614 kbps:

    ffmpeg -f lavfi -i "anoisesrc=color=pink:sample_rate=48000:amplitude=0.5" -ac 2 -t 90 \
      -c:a flac -sample_fmt s16 -metadata title="Test track" -metadata artist="Test" \
      -metadata album="Test album" "01 - Test track.flac"

One thing worth knowing before you try it: the source has to be big enough to force a
transcode. My first attempt was a sine tone, which FLAC squeezes down to 118 kbps — under
the MaxStreamingBitrate=192000 in the request — so the server direct-played it and nothing
failed. With a source above the limit it fails every time.

The request is the same one from my first post, plus a PlaySessionId:

    GET /Audio/{id}/universal?UserId={uid}&DeviceId={dev}&MaxStreamingBitrate=192000
        &Container=mp3,aac,m4a&AudioCodec={codec}&PlaySessionId={psid}
        &TranscodingProtocol=hls&TranscodingContainer={mp4|ts}

The playlist is served correctly either way — 30 segments, #EXT-X-VERSION:7 with EXT-X-MAP
for mp4, #EXT-X-VERSION:3 for ts. It is the segments that differ, and it does not depend on
the codec I ask for:

    AudioCodec   TranscodingContainer=mp4        TranscodingContainer=ts
    aac          500 (init.mp4 and every seg)    200,  91,556 B
    mp3          500                             200,  86,856 B
    opus         500                             200,  70,312 B
    flac         500                             200, 247,784 B
    alac         500                             200, 251,544 B

All ten cells, same session pattern, same file. Every 500 body is "Object reference not set
to an instance of an object.", and the stack in your log is the same one I sent in August:

    FfRunException: Object reference not set to an instance of an object.
     ---> System.NullReferenceException
       at Emby.Server.MediaEncoding.Encoder.TranscodingCommandBuilder.HlsGetCommandLineArguments(...)
       at Emby.Server.MediaEncoding.Api.Hls.DynamicHlsService.GetCommandLineArguments(...)
       at Emby.Server.MediaEncoding.Api.BaseStreamingService.StartFfMpeg(...)
       at Emby.Server.MediaEncoding.Api.Hls.DynamicHlsService.GetDynamicSegment(...)

And ffmpeg never launches for the mp4 path: across that run your log has 12 "ProcessRun
'StreamTranscode' ... Execute" lines for the 12 ts segment requests, and zero for the 16 mp4
ones. It fails while assembling the command line, before any process starts.

Happy to run anything else against this container while I have it, or to attach the log.

Posted

I guess compare to a web app url for that endpoint?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...